Set-up

Loading packages & custom functions

library(readr)
library(dplyr)
library(metafor)
library(devtools)
library(purrr)
library(tidyverse)
library(tidyr)
library(tibble)
library(kableExtra)
library(robumeta)
library(ggpubr)
library(ggplot2)
library(here)

Functions

for preparing the data for meta analyses

1) Subsetting data

Create function for sub-setting the data to choose only one data point per individual per trait: “data_subset_parameterid_individual_by_age”

data_subset_parameterid_individual_by_age <- function(mydata, parameter, age_min = 0, 
    age_center = 100) {
    tmp <- mydata %>% filter(age_in_days >= age_min, id == parameter) %>% # take results for single individual closest to age_center
    mutate(age_diff = abs(age_center - age_in_days)) %>% group_by(biological_sample_id) %>% 
        filter(age_diff == min(age_diff)) %>% select(-age_diff)  # %>% 
    # filter(!duplicated(biological_sample_id)) #Felix 6/2/2020: this line can
    # be deleted
    
    # still some individuals with multiple records (because same individual
    # appear under different procedures, so filter to one record)
    j <- match(unique(tmp$biological_sample_id), tmp$biological_sample_id)
    tmp[j, ]
}

2) “Population statistics”

Create function called: “calculate_population_stats” This function groups animals from the same strain and same insitiution together. This is done for each trait seoarately, and only for traits that have been measured in both sexes. Any group containing fewer than 5 individuals is excluded.

calculate_population_stats <- function(mydata, min_individuals = 5) {
    mydata %>% group_by(population, strain_name, production_center, sex) %>% 
        summarise(trait = parameter_name[1], x_bar = mean(data_point), x_sd = sd(data_point), 
            n_ind = n()) %>% ungroup() %>% filter(n_ind > min_individuals) %>% 
        # Check both sexes present & filter those missing
    group_by(population) %>% mutate(n_sex = n_distinct(sex)) %>% ungroup() %>% 
        filter(n_sex == 2) %>% select(-n_sex) %>% arrange(production_center, 
        strain_name, population, sex)
}

3) Extraction of effect sizes and sample variances

Function: “create_meta_analysis_effect_sizes”

create_meta_analysis_effect_sizes <- function(mydata) {
    i <- seq(1, nrow(mydata), by = 2)
    input <- data.frame(n1i = mydata$n_ind[i], n2i = mydata$n_ind[i + 1], x1i = mydata$x_bar[i], 
        x2i = mydata$x_bar[i + 1], sd1i = mydata$x_sd[i], sd2i = mydata$x_sd[i + 
            1])
    
    mydata[i, ] %>% select(strain_name, production_center, trait) %>% mutate(effect_size_CVR = calculate_lnCVR(CMean = input$x1i, 
        CSD = input$sd1i, CN = input$n1i, EMean = input$x2i, ESD = input$sd2i, 
        EN = input$n2i), sample_variance_CVR = calculate_var_lnCVR(CMean = input$x1i, 
        CSD = input$sd1i, CN = input$n1i, EMean = input$x2i, ESD = input$sd2i, 
        EN = input$n2i), effect_size_VR = calculate_lnVR(CSD = input$sd1i, CN = input$n1i, 
        ESD = input$sd2i, EN = input$n2i), sample_variance_VR = calculate_var_lnVR(CN = input$n1i, 
        EN = input$n2i), effect_size_RR = calculate_lnRR(CMean = input$x1i, 
        CSD = input$sd1i, CN = input$n1i, EMean = input$x2i, ESD = input$sd2i, 
        EN = input$n2i), sample_variance_RR = calculate_var_lnRR(CMean = input$x1i, 
        CSD = input$sd1i, CN = input$n1i, EMean = input$x2i, ESD = input$sd2i, 
        EN = input$n2i), err = as.factor(seq_len(n())))
}

4) Calculate meta-analysis statistics

Based on a function created by A M Senior @ the University of Otago NZ 03/01/2014:

  • Calculates effect sizes for meta-analysis of variance. All functions take the mean, sd and n from the control and experimental groups.
  • The first function, calculate_lnCVR, calculates the the log response-ratio of the coefficient of variance (lnCVR) - see Nakagawa et al 2015.
  • The second function calculates the measurement error variance for lnCVR. As well as the aforementioned parameters, this function also takes Equal_E_C_Corr (default = T), which must be True or False. If true, the function assumes that the correlation between mean and sd (Taylor’s Law) is equal for the mean and control groups, and, thus these data are pooled. If False the mean-SD correlation for the experimental and control groups are calculated separately from one another.
  • Similar functions are then implemented for lnVR (for comparison of standard deviations) and ln RR (for comparison of means)
calculate_lnCVR <- function(CMean, CSD, CN, EMean, ESD, EN) {
    log(ESD) - log(EMean) + 1/(2 * (EN - 1)) - (log(CSD) - log(CMean) + 1/(2 * 
        (CN - 1)))
}

calculate_var_lnCVR <- function(CMean, CSD, CN, EMean, ESD, EN, Equal_E_C_Corr = T) {
    if (Equal_E_C_Corr == T) {
        mvcorr <- 0  # cor.test(log(c(CMean, EMean)), log(c(CSD, ESD)))$estimate   old, slightly incorrect
        S2 <- CSD^2/(CN * (CMean^2)) + 1/(2 * (CN - 1)) - 2 * mvcorr * sqrt((CSD^2/(CN * 
            (CMean^2))) * (1/(2 * (CN - 1)))) + ESD^2/(EN * (EMean^2)) + 1/(2 * 
            (EN - 1)) - 2 * mvcorr * sqrt((ESD^2/(EN * (EMean^2))) * (1/(2 * 
            (EN - 1))))
    } else {
        Cmvcorr <- cor.test(log(CMean), log(CSD))$estimate
        Emvcorr <- cor.test(log(EMean), (ESD))$estimate
        S2 <- CSD^2/(CN * (CMean^2)) + 1/(2 * (CN - 1)) - 2 * Cmvcorr * sqrt((CSD^2/(CN * 
            (CMean^2))) * (1/(2 * (CN - 1)))) + ESD^2/(EN * (EMean^2)) + 1/(2 * 
            (EN - 1)) - 2 * Emvcorr * sqrt((ESD^2/(EN * (EMean^2))) * (1/(2 * 
            (EN - 1))))
    }
    S2
}

calculate_lnVR <- function(CSD, CN, ESD, EN) {
    log(ESD) - log(CSD) + 1/(2 * (EN - 1)) - 1/(2 * (CN - 1))
}

calculate_var_lnVR <- function(CN, EN) {
    1/(2 * (EN - 1)) + 1/(2 * (CN - 1))
}

calculate_lnRR <- function(CMean, CSD, CN, EMean, ESD, EN) {
    log(EMean) - log(CMean)
}

calculate_var_lnRR <- function(CMean, CSD, CN, EMean, ESD, EN) {
    CSD^2/(CN * CMean^2) + ESD^2/(EN * EMean^2)
}

Load & clean data

1) Data loading and cleaning of the csv file

This step we have already done and provide a cleaned up file which is less computing intensive and which we have saved in a folder called export. However, the cvs is provided in case this is preferred to be attempted, following the steps below:

# loads the raw data, setting some default types for various columns

load_raw <- function(filename) {
    read_csv(filename, col_types = cols(.default = col_character(), project_id = col_character(), 
        id = col_character(), parameter_id = col_character(), age_in_days = col_integer(), 
        date_of_experiment = col_datetime(format = ""), weight = col_double(), 
        phenotyping_center_id = col_character(), production_center_id = col_character(), 
        weight_date = col_datetime(format = ""), date_of_birth = col_datetime(format = ""), 
        procedure_id = col_character(), pipeline_id = col_character(), biological_sample_id = col_character(), 
        biological_model_id = col_character(), weight_days_old = col_integer(), 
        datasource_id = col_character(), experiment_id = col_character(), data_point = col_double(), 
        age_in_weeks = col_integer(), `_version_` = col_character()))
}

# Apply some standard cleaning to the data
clean_raw_data <- function(mydata) {
    
    group <- read_csv(here("data", "ParameterGrouping.csv"))
    
    tmp <- mydata %>% 
    # Filter to IMPC source (recommend by Jeremey in email to Susi on 20 Aug
    # 2018)
    filter(datasource_name == "IMPC") %>% 
    # standardise trait names
    mutate(parameter_name = tolower(parameter_name)) %>% 
    # remove extreme ages
    filter(age_in_days > 0 & age_in_days < 500) %>% 
    # remove NAs
    filter(!is.na(data_point)) %>% 
    # subset to reasonable set of variables, date_of_experiment used as an
    # indicator of batch-level effects
    select(production_center, strain_name, strain_accession_id, biological_sample_id, 
        pipeline_stable_id, procedure_group, procedure_name, sex, date_of_experiment, 
        age_in_days, weight, parameter_name, data_point) %>% 
    # sort
    arrange(production_center, biological_sample_id, age_in_days)
    
    # filter to groups with > 1 centre
    merge(tmp, tmp %>% group_by(parameter_name) %>% summarise(center_per_trait = length(unique(production_center, 
        na.rm = TRUE)))) %>% filter(center_per_trait >= 2) %>% 
    # Define population variable
    mutate(population = sprintf("%s-%s", production_center, strain_name)) %>% 
        
    # add grouping variable: these were decided based on functional groups and
    # procedures
    mutate(parameter_group = group$parameter[match(parameter_name, group$parameter_name)]) %>% 
        
    # Assign unique IDs (per trait) each unique parameter_name (=trait,use trait
    # variable) gets a unique number ('id')
    
    # We add a new variable, where redundant traits are combined [note however,
    # at this stage the dataset still contains nonsensical traits, i.e. traits
    # that may not contain any information on variance]
    mutate(id = match(parameter_name, unique(parameter_name))) %>% as_tibble()
}

# Load raw data - save cleaned dataset as RDS for reuse
data_raw <- load_raw(here("data", "dr7.0_all_control_data.csv.gz"))
dir.create("export", F, F)

data <- data_raw %>% clean_raw_data()
saveRDS(data, "export/data_clean.rds")

For analysis we load the RDS created above and other datasets:

data <- readRDS(here("export", "data_clean.rds"))

procedures <- read_csv(here("data", "procedures.csv"))

Checking length of different variables and sample sizes.

Table 1: “Strains and Center Sample Sizes”

This table summarises the available numbers of male and female mice from each strain and originating institution.

## # A tibble: 46 x 4
## # Groups:   production_center, strain_name [24]
##    production_center strain_name                            sex         n
##    <chr>             <chr>                                  <chr>   <int>
##  1 BCM               C57BL/6N                               female    653
##  2 BCM               C57BL/6N                               male      639
##  3 BCM               C57BL/6N;C57BL/6NTac                   female     47
##  4 BCM               C57BL/6N;C57BL/6NTac                   male       52
##  5 BCM               C57BL/6NCrl                            female      4
##  6 BCM               C57BL/6NCrl                            male        2
##  7 BCM               C57BL/6NJ                              female      6
##  8 BCM               C57BL/6NJ                              male        6
##  9 BCM               C57BL/6NTac                            female      1
## 10 BCM               C57BL/6NTac                            male        5
## 11 HMGU              C57BL/6NCrl                            female    313
## 12 HMGU              C57BL/6NCrl                            male      311
## 13 HMGU              C57BL/6NTac                            female   1045
## 14 HMGU              C57BL/6NTac                            male     1062
## 15 ICS               C57BL/6N                               female   1025
## 16 ICS               C57BL/6N                               male     1050
## 17 JAX               C57BL/6NJ                              female   2025
## 18 JAX               C57BL/6NJ                              male     2022
## 19 KMPC              C57BL/6N;C57BL/6NTac                   female    271
## 20 KMPC              C57BL/6N;C57BL/6NTac                   male      266
## 21 MARC              C57BL/6N                               female    936
## 22 MARC              C57BL/6N                               male      926
## 23 MRC Harwell       C57BL/6NTac                            female   2639
## 24 MRC Harwell       C57BL/6NTac                            male     2661
## 25 MRC Harwell       C57BL/6NTac                            no_data     3
## 26 RBRC              C57BL/6NJcl                            female    222
## 27 RBRC              C57BL/6NJcl                            male      222
## 28 RBRC              C57BL/6NTac                            female    526
## 29 RBRC              C57BL/6NTac                            male      523
## 30 TCP               C57BL/6NCrl                            female    552
## 31 TCP               C57BL/6NCrl                            male      524
## 32 TCP               C57BL6/NCrl                            female      2
## 33 TCP               C57BL6/NCrl                            male        2
## 34 UC Davis          C57BL/6N                               male        1
## 35 UC Davis          C57BL/6NCrl                            female   1155
## 36 UC Davis          C57BL/6NCrl                            male     1158
## 37 WTSI              B6Brd;B6Dnk;B6N-Tyr<c-Brd>             female     97
## 38 WTSI              B6Brd;B6Dnk;B6N-Tyr<c-Brd>             male       87
## 39 WTSI              C57BL/6J-Tyr<c-Brd> or C57BL/6NTac/USA male        3
## 40 WTSI              C57BL/6N                               female   1951
## 41 WTSI              C57BL/6N                               male     2008
## 42 WTSI              C57BL/6N;C57BL/6NTac                   female     41
## 43 WTSI              C57BL/6N;C57BL/6NTac                   male        7
## 44 WTSI              C57BL/6NCrl                            male       13
## 45 WTSI              C57BL/6NTac                            female     49
## 46 WTSI              C57BL/6NTac                            male       34
production_center strain_name sex n
BCM C57BL/6N female 653
BCM C57BL/6N male 639
BCM C57BL/6N;C57BL/6NTac female 47
BCM C57BL/6N;C57BL/6NTac male 52
BCM C57BL/6NCrl female 4
BCM C57BL/6NCrl male 2
BCM C57BL/6NJ female 6
BCM C57BL/6NJ male 6
BCM C57BL/6NTac female 1
BCM C57BL/6NTac male 5
HMGU C57BL/6NCrl female 313
HMGU C57BL/6NCrl male 311
HMGU C57BL/6NTac female 1045
HMGU C57BL/6NTac male 1062
ICS C57BL/6N female 1025
ICS C57BL/6N male 1050
JAX C57BL/6NJ female 2025
JAX C57BL/6NJ male 2022
KMPC C57BL/6N;C57BL/6NTac female 271
KMPC C57BL/6N;C57BL/6NTac male 266
MARC C57BL/6N female 936
MARC C57BL/6N male 926
MRC Harwell C57BL/6NTac female 2639
MRC Harwell C57BL/6NTac male 2661
MRC Harwell C57BL/6NTac no_data 3
RBRC C57BL/6NJcl female 222
RBRC C57BL/6NJcl male 222
RBRC C57BL/6NTac female 526
RBRC C57BL/6NTac male 523
TCP C57BL/6NCrl female 552
TCP C57BL/6NCrl male 524
TCP C57BL6/NCrl female 2
TCP C57BL6/NCrl male 2
UC Davis C57BL/6N male 1
UC Davis C57BL/6NCrl female 1155
UC Davis C57BL/6NCrl male 1158
WTSI B6Brd;B6Dnk;B6N-Tyr<c-Brd> female 97
WTSI B6Brd;B6Dnk;B6N-Tyr<c-Brd> male 87
WTSI C57BL/6J-Tyr<c-Brd> or C57BL/6NTac/USA male 3
WTSI C57BL/6N female 1951
WTSI C57BL/6N male 2008
WTSI C57BL/6N;C57BL/6NTac female 41
WTSI C57BL/6N;C57BL/6NTac male 7
WTSI C57BL/6NCrl male 13
WTSI C57BL/6NTac female 49
WTSI C57BL/6NTac male 34

Meta-analyses

1. Population as analysis unit

(Step C, Figure 3 in main document)

Loop: Meta-analyses on all traits

  • The loop combines the functions mentioned above and fills the data matrix with results from our meta analysis.
  • Error messages indicate traits that either did not reach convergence, or that did not return meaningful results in the meta-analysis, due to absence of variance. Those traits will be removed in later steps, outlined below.
n <- length(unique(data$id))

# Create dataframe to store results
results_alltraits_grouping <- tibble(id = 1:n, lnCVR = 0, lnCVR_lower = 0, lnCVR_upper = 0, 
    lnCVR_se = 0, lnVR = 0, lnVR_lower = 0, lnVR_upper = 0, lnVR_se = 0, lnRR = 0, 
    lnRR_lower = 0, lnRR_upper = 0, lnRR_se = 0, sampleSize = 0, trait = 0)

for (t in 1:n) {
    tryCatch({
        results <- data %>% data_subset_parameterid_individual_by_age(t) %>% 
            calculate_population_stats() %>% create_meta_analysis_effect_sizes()
        
        # lnCVR, log repsonse-ratio of the coefficient of variance
        cvr <- metafor::rma.mv(yi = effect_size_CVR, V = sample_variance_CVR, 
            random = list(~1 | strain_name, ~1 | production_center, ~1 | err), 
            control = list(optimizer = "optim", optmethod = "Nelder-Mead", maxit = 1000), 
            verbose = F, data = results)
        
        # lnVR, comparison of standard deviations
        cv <- metafor::rma.mv(yi = effect_size_VR, V = sample_variance_VR, random = list(~1 | 
            strain_name, ~1 | production_center, ~1 | err), control = list(optimizer = "optim", 
            optmethod = "Nelder-Mead", maxit = 1000), verbose = F, data = results)
        
        # for means, lnRR
        means <- metafor::rma.mv(yi = effect_size_RR, V = sample_variance_RR, 
            random = list(~1 | strain_name, ~1 | production_center, ~1 | err), 
            control = list(optimizer = "optim", optmethod = "Nelder-Mead", maxit = 1000), 
            verbose = F, data = results)
        
        f <- function(x) unlist(x[c("b", "ci.lb", "ci.ub", "se")])
        
        results_alltraits_grouping[t, 2:14] <- c(f(cvr), f(cv), f(means), means$k)
        results_alltraits_grouping[t, 15] <- unique(results$trait)
    }, error = function(e) {
        cat("ERROR :", t, conditionMessage(e), "\n")
    })
}
## ERROR : 84 Optimizer (optim) did not achieve convergence (convergence = 10). 
## ERROR : 158 Optimizer (optim) did not achieve convergence (convergence = 10). 
## ERROR : 160 NA/NaN/Inf in 'y' 
## ERROR : 161 NA/NaN/Inf in 'y' 
## ERROR : 162 NA/NaN/Inf in 'y' 
## ERROR : 163 NA/NaN/Inf in 'y' 
## ERROR : 165 NA/NaN/Inf in 'y' 
## ERROR : 166 NA/NaN/Inf in 'y' 
## ERROR : 168 NA/NaN/Inf in 'y' 
## ERROR : 231 NA/NaN/Inf in 'y'

In the above function, we use ‘tryCatch’ and ‘conditionMessage’ to prevent the loop from aborting when the first error at row 84 is produced. As convergence in the two listed non-converging cases can’t be achieved by sensibly tweaking (other optim etc.), and we only learn about non-convergence in the loop, it is not possible to exclude the traits (N=2) beforehand. Similarly, there are 8 traits with very low variation, which can not be excluded prior to running the loop.

The produced “Warnings” indicate cases where variance components are set to zero during likelihood optimization.

Merging datasets & removal of non-converged traits

Procedure names, grouping variables and trait names (“parameter_names”) are merged back together with the results from the metafor analysis above.

results_alltraits_grouping2 <- 
  results_alltraits_grouping %>% 
  left_join(by="id",
             data %>% select(id, parameter_group, procedure = procedure_name, procedure_name, parameter_name) %>%   # We filter duplicated id's to get only one unique row per id (and there is one id per parameter_name)
              filter(!duplicated(id))
            ) %>%
  # Below we add 'procedure' (from the previously loaded 'procedures.csv') as a variable
  left_join(by="procedure", 
            procedures %>% distinct()
            )

#(n <- length(unique(results_alltraits_grouping2$parameter_name))) # 232

Removal of traits

14 traits from the originally 232 that had been included are removed because they either did not achieve convergence or are nonsensical for analysis of variance (such as traits that show no variation, see list below).

Not converged: “dp t cells”, “mzb (cd21/35 high)”

Not enough variation: “number of caudal vertebrae”, “number of cervical vertebrae”, “number of digits”, “number of lumbar vertebrae”, “number of pelvic vertebrae”, “number of ribs left”,“number of ribs right”, “number of signals”, “number of thoracic vertebrae”, “total number of acquired events in panel a”,“total number of acquired events in panel b”, “whole arena permanence”.

# We exclude 14 parameter names for which metafor models didn't converge
# ('dp t cells', 'mzb (cd21/35 high)'), and of parameters that don't harbour
# enough variation
meta_clean <- results_alltraits_grouping2 %>% filter(!parameter_name %in% c("dp t cells", 
    "mzb (cd21/35 high)", "number of caudal vertebrae", "number of cervical vertebrae", 
    "number of digits", "number of lumbar vertebrae", "number of pelvic vertebrae", 
    "number of ribs left", "number of ribs right", "number of signals", "number of thoracic vertebrae", 
    "total number of acquired events in panel a", "total number of acquired events in panel b", 
    "whole arena permanence"))

2. Meta-analysis: condensing non-independent traits

(Step F in Figure 3 in main article)

Dealing with Correlated Parameters, preparation

This dataset contained a number of highly correlated traits, such as different kinds of cell counts (for example hierarchical parameterization within immunological assays). As those data-points are not independent of each other, we conducted meta analyses on these correlated parameters to collapse the number of levels.

Collapsing and merging correlated parameters

Here we double check numbers of trait parameters in the dataset

meta1 <- meta_clean
length(unique(meta1$procedure))  #18
## [1] 18
length(unique(meta1$GroupingTerm))  #9
## [1] 9
length(unique(meta1$parameter_group))  # 148 levels. To be used as grouping factor for meta-meta-analysis / collapsing down based on things that are classified identically in 'parameter_group' but have different 'parameter_name'
## [1] 148
length(unique(meta1$parameter_name))  #218
## [1] 218

Count of number of parameter names (correlated sub-traits) in each parameter group (par_group_size)

Table 2: Numbers of correlated and uncorrelated traits

This serves to identify and separate the traits that are correlated from the full dataset that can be processed as is. If the sample size (n) for a given “parameter group” equals 1, the trait is unique and uncorrelated. All instances, where there are 2 or more traits associated with the same parameter group (90 cases), are selected for a “mini-meta analysis”, which removes the issue of correlation.

kable(cbind(meta1 %>% count(parameter_group))) %>% kable_styling() %>% scroll_box(width = "60%", 
    height = "200px")
parameter_group n
12khz-evoked abr threshold 1
18khz-evoked abr threshold 1
24khz-evoked abr threshold 1
30khz-evoked abr threshold 1
6khz-evoked abr threshold 1
alanine aminotransferase 1
albumin 1
alkaline phosphatase 1
alpha-amylase 1
area under glucose response curve 1
aspartate aminotransferase 1
B cells 4
basophil cell count 1
basophil differential count 1
bmc/body weight 1
body length 1
body temp 1
body weight 1
body weight after experiment 1
body weight before experiment 1
bone area 1
bone mineral content (excluding skull) 1
bone mineral density (excluding skull) 1
calcium 1
cardiac output 1
cd4 nkt 6
cd4 t 7
cd8 nkt 6
cd8 t 7
cdcs 2
center average speed 1
center distance travelled 1
center permanence time 1
center resting time 1
chloride 1
click-evoked abr threshold 1
creatine kinase 1
creatinine 1
cv 1
distance travelled - total 1
dn nkt 6
dn t 7
ejection fraction 1
end-diastolic diameter 1
end-systolic diameter 1
eosinophils 3
fasted blood glucose concentration 1
fat mass 1
fat/body weight 1
follicular b cells 2
forelimb and hindlimb grip strength measurement mean 1
forelimb grip strength measurement mean 1
fractional shortening 1
free fatty acids 1
fructosamine 1
glucose 1
hdl-cholesterol 1
heart weight 1
heart weight normalised against body weight 1
hematocrit 1
hemoglobin 1
hr 1
hrv 1
initial response to glucose challenge 1
insulin 1
iron 1
lactate dehydrogenase 1
latency to center entry 1
ldl-cholesterol 1
lean mass 1
lean/body weight 1
left anterior chamber depth 1
left corneal thickness 1
left inner nuclear layer 1
left outer nuclear layer 1
left posterior chamber depth 1
left total retinal thickness 1
locomotor activity 1
luc 2
lvawd 1
lvaws 1
lvidd 1
lvids 1
lvpwd 1
lvpws 1
lymphocytes 2
magnesium 1
mean cell hemoglobin concentration 1
mean cell volume 1
mean corpuscular hemoglobin 1
mean platelet volume 1
mean r amplitude 1
mean sr amplitude 1
monocytes 3
neutrophils 3
nk cells 6
nkt cells 4
number of center entries 1
number of rears - total 1
others 1
pdcs 1
percentage center time 1
percentage of live gated events 2
periphery average speed 1
periphery distance travelled 1
periphery permanence time 1
periphery resting time 1
phosphorus 1
platelet count 1
pnn5(6>ms) 1
potassium 1
pq 1
pr 1
pre-pulse inhibition 5
qrs 1
qtc 1
qtc dispersion 1
red blood cell count 1
red blood cell distribution width 1
respiration rate 1
respiratory exchange ratio 1
response amplitude 10
right anterior chamber depth 1
right corneal thickness 1
right inner nuclear layer 1
right outer nuclear layer 1
right posterior chamber depth 1
right total retinal thickness 1
rmssd 1
rp macrophage (cd19- cd11c-) 1
rr 1
sodium 1
spleen weight 1
st 1
stroke volume 1
t cells 3
tibia length 1
total bilirubin 1
total cholesterol 1
total food intake 1
total protein 1
total water intake 1
triglycerides 1
urea (blood urea nitrogen - bun) 1
uric acid 1
white blood cell count 1
whole arena average speed 1
whole arena resting time 1
meta1_sub <- meta1 %>% # Add summary of number of parameter names in each parameter group
group_by(parameter_group) %>% mutate(par_group_size = length(unique(parameter_name)), 
    sampleSize = as.numeric(sampleSize)) %>% ungroup() %>% # Create subsets with > 1 count (par_group_size > 1)
filter(par_group_size > 1)  # 90 observations

Meta-analyses on correlated (sub-)traits, using robumeta`

Here we pepare the subset of the data (using nest()), and in this first step the model of the meta-analysis effect sizes are calculated

# Create summary of number of parameter names in each parameter group, and
# merge back together

meta1b <- meta1 %>% group_by(parameter_group) %>% summarize(par_group_size = length(unique(parameter_name, 
    na.rm = TRUE)))

meta1$par_group_size <- meta1b$par_group_size[match(meta1$parameter_group, meta1b$parameter_group)]

# Create subsets with > 1 count (par_group_size > 1)

meta1_sub <- subset(meta1, par_group_size > 1)  # 90 observations   
meta1_sub$sampleSize <- as.numeric(meta1_sub$sampleSize)

# Nesting and meta-analyses on correlated traits, using robumeta

n_count <- meta1_sub %>% group_by(parameter_group) %>% mutate(raw_N = sum(sampleSize)) %>% 
    nest() %>% ungroup()

model_count <- n_count %>% mutate(model_lnRR = map(data, ~robu(.x$lnRR ~ 1, 
    data = .x, studynum = .x$id, modelweights = c("CORR"), rho = 0.8, small = TRUE, 
    var.eff.size = (.x$lnRR_se)^2)), model_lnVR = map(data, ~robu(.x$lnVR ~ 
    1, data = .x, studynum = .x$id, modelweights = c("CORR"), rho = 0.8, small = TRUE, 
    var.eff.size = (.x$lnVR_se)^2)), model_lnCVR = map(data, ~robu(.x$lnCVR ~ 
    1, data = .x, studynum = .x$id, modelweights = c("CORR"), rho = 0.8, small = TRUE, 
    var.eff.size = (.x$lnCVR_se)^2)))

Extracting and save parameter estimates

Here we apply an additional Function to collect the outcomes of the ‘mini-meta-analysis’ that has ondensed our non-independent traits.

count_fun <- function(mod_sub) {
    return(c(mod_sub$reg_table$b.r, mod_sub$reg_table$CI.L, mod_sub$reg_table$CI.U, 
        mod_sub$reg_table$SE))
}  # estimate, lower ci, upper ci, SE

Extraction of values created during meta-analyses using robumeta

robusub_RR <- model_count %>% transmute(parameter_group, estimatelnRR = map(model_lnRR, 
    count_fun)) %>% mutate(r = map(estimatelnRR, ~data.frame(t(.)))) %>% unnest(r) %>% 
    select(-estimatelnRR) %>% purrr::set_names(c("parameter_group", "lnRR", 
    "lnRR_lower", "lnRR_upper", "lnRR_se"))

robusub_CVR <- model_count %>% transmute(parameter_group, estimatelnCVR = map(model_lnCVR, 
    count_fun)) %>% mutate(r = map(estimatelnCVR, ~data.frame(t(.)))) %>% unnest(r) %>% 
    select(-estimatelnCVR) %>% purrr::set_names(c("parameter_group", "lnCVR", 
    "lnCVR_lower", "lnCVR_upper", "lnCVR_se"))

robusub_VR <- model_count %>% transmute(parameter_group, estimatelnVR = map(model_lnVR, 
    count_fun)) %>% mutate(r = map(estimatelnVR, ~data.frame(t(.)))) %>% unnest(r) %>% 
    select(-estimatelnVR) %>% purrr::set_names(c("parameter_group", "lnVR", 
    "lnVR_lower", "lnVR_upper", "lnVR_se"))

robu_all <- full_join(robusub_CVR, robusub_VR) %>% full_join(., robusub_RR)

Combining data

Merge the two data sets (the new [robu_all] and the initial [uncorrelated sub-traits with count = 1])

meta_all <- meta1 %>% filter(par_group_size == 1) %>% as_tibble()
# glimpse(meta_all) glimpse(robu_all)

# Step 1: Columns are matched by name (in our case, 'parameter_group'), and
# any missing columns will be filled with NA
combinedmeta <- bind_rows(robu_all, meta_all)
# glimpse(combinedmeta)

# Steps 2&3: Add information about number of traits in a parameter group,
# procedure, and grouping term
metacombo <- combinedmeta
metacombo$counts <- meta1$par_group_size[match(metacombo$parameter_group, meta1$parameter_group)]
metacombo$procedure2 <- meta1$procedure[match(metacombo$parameter_group, meta1$parameter_group)]
metacombo$GroupingTerm2 <- meta1$GroupingTerm[match(metacombo$parameter_group, 
    meta1$parameter_group)]

Clean-up, reorder, and rename

metacombo <- metacombo[c("parameter_group", "counts", "procedure2", "GroupingTerm2", 
    "lnCVR", "lnCVR_lower", "lnCVR_upper", "lnCVR_se", "lnVR", "lnVR_lower", 
    "lnVR_upper", "lnVR_se", "lnRR", "lnRR_lower", "lnRR_upper", "lnRR_se")]

names(metacombo)[names(metacombo) == "procedure2"] <- "procedure"
names(metacombo)[names(metacombo) == "GroupingTerm2"] <- "GroupingTerm"

# Quick pre-check before doing plots
metacombo %>% group_by(GroupingTerm) %>% dplyr::summarize(MeanCVR = mean(lnCVR), 
    MeanVR = mean(lnVR), MeanRR = mean(lnRR))
## # A tibble: 9 x 4
##   GroupingTerm   MeanCVR   MeanVR   MeanRR
##   <chr>            <dbl>    <dbl>    <dbl>
## 1 Behaviour     0.000871 -0.00727 -0.00869
## 2 Eye          -0.152    -0.146    0.00656
## 3 Hearing       0.0143   -0.00893 -0.0145 
## 4 Heart         0.0225   -0.0126  -0.0312 
## 5 Hematology    0.0295    0.106    0.0665 
## 6 Immunology   -0.0723   -0.107   -0.0528 
## 7 Metabolism   -0.0503    0.0931   0.161  
## 8 Morphology    0.0730    0.143    0.0684 
## 9 Physiology    0.0236    0.0480   0.0227

Table 3: Full corrected dataset

We use this corrected (for correlated traits) “results” table, which contains each of the meta-analytic means for all effect sizes of interest, for further analyses. We further use this table as part of the Shiny App, which is able to provide the percentage differences between males and females for mean, variance and coefficient of variance.

This is the full result dataset

kable(metacombo) %>% kable_styling() %>% scroll_box(width = "100%", height = "200px")
parameter_group counts procedure GroupingTerm lnCVR lnCVR_lower lnCVR_upper lnCVR_se lnVR lnVR_lower lnVR_upper lnVR_se lnRR lnRR_lower lnRR_upper lnRR_se
pre-pulse inhibition 5 Acoustic Startle and Pre-pulse Inhibition (PPI) Behaviour 0.0232963 -0.0802563 0.1268488 0.0370507 0.0091028 -0.0364640 0.0546695 0.0143431 -0.0052156 -0.0427126 0.0322815 0.0128092
B cells 4 Immunophenotyping Immunology -0.0938959 -0.2500020 0.0622103 0.0426972 -0.0995337 -0.2068001 0.0077328 0.0250132 -0.0026281 -0.1298230 0.1245668 0.0393018
cd4 nkt 6 Immunophenotyping Immunology -0.0287688 -0.0566987 -0.0008389 0.0101634 -0.2018746 -0.3102294 -0.0935198 0.0331161 -0.2344450 -0.4005266 -0.0683635 0.0633501
cd4 t 7 Immunophenotyping Immunology -0.1507387 -0.2427976 -0.0586798 0.0360690 -0.1699213 -0.2629450 -0.0768975 0.0348324 -0.0031242 -0.0411564 0.0349081 0.0148989
cd8 nkt 6 Immunophenotyping Immunology -0.0424402 -0.0782046 -0.0066759 0.0119223 -0.0300442 -0.1823594 0.1222710 0.0533765 0.0035372 -0.0573749 0.0644494 0.0205272
cd8 t 7 Immunophenotyping Immunology -0.1223681 -0.2179976 -0.0267387 0.0358727 -0.1581698 -0.2342579 -0.0820816 0.0270229 -0.0415806 -0.0510391 -0.0321221 0.0023119
cdcs 2 Immunophenotyping Immunology -0.0362947 -0.3588637 0.2862742 0.0253867 0.1080248 -0.0565718 0.2726213 0.0129540 0.1642541 -0.1701520 0.4986601 0.0263183
dn nkt 6 Immunophenotyping Immunology -0.0619371 -0.1359380 0.0120637 0.0257746 -0.1572129 -0.2814342 -0.0329915 0.0447163 -0.1727105 -0.2906356 -0.0547854 0.0441034
dn t 7 Immunophenotyping Immunology -0.0796127 -0.1844481 0.0252227 0.0420063 -0.2421038 -0.3431678 -0.1410397 0.0406314 -0.2298147 -0.2519708 -0.2076586 0.0072373
eosinophils 3 Hematology Hematology -0.0662225 -0.2806631 0.1482181 0.0325859 -0.0154112 -0.4051652 0.3743427 0.0865366 -0.0042422 -0.2409206 0.2324362 0.0508093
follicular b cells 2 Immunophenotyping Immunology -0.1160077 -0.7256692 0.4936538 0.0479814 -0.1050194 -0.6946364 0.4845977 0.0464039 0.0052427 -0.1872381 0.1977236 0.0151486
luc 2 Hematology Hematology 0.0180436 -0.2038464 0.2399336 0.0174631 0.2657035 -1.2251358 1.7565428 0.1173316 0.2215497 -1.4136389 1.8567382 0.1286921
lymphocytes 2 Hematology Hematology 0.0805230 -2.2618128 2.4228588 0.1843458 0.1550159 -1.0892706 1.3993024 0.0979275 0.0602144 -1.0131287 1.1335576 0.0844739
monocytes 3 Hematology Hematology -0.0214677 -0.2033706 0.1604352 0.0420605 0.0784876 -0.1811005 0.3380757 0.0585593 0.1025193 -0.1483375 0.3533762 0.0571438
neutrophils 3 Hematology Hematology 0.2587446 0.0130803 0.5044089 0.0557516 0.3799805 -0.2060446 0.9660057 0.1317980 0.1319372 -0.2669324 0.5308068 0.0924336
nk cells 6 Immunophenotyping Immunology -0.0414772 -0.0960406 0.0130862 0.0200411 0.0156533 -0.0703789 0.1016856 0.0315487 0.0471757 -0.0162213 0.1105728 0.0231831
nkt cells 4 Immunophenotyping Immunology 0.0033757 -0.1069890 0.1137404 0.0294661 -0.2458705 -0.4452333 -0.0465077 0.0426738 -0.1823355 -0.3233946 -0.0412763 0.0314580
percentage of live gated events 2 Immunophenotyping Immunology -0.0934933 -0.3037340 0.1167473 0.0165463 -0.0412606 -0.1414443 0.0589231 0.0078846 0.0500941 0.0081191 0.0920690 0.0033035
response amplitude 10 Acoustic Startle and Pre-pulse Inhibition (PPI) Behaviour 0.0333147 -0.0127585 0.0793879 0.0202947 0.2549274 0.1969787 0.3128761 0.0255003 0.2016062 0.1108136 0.2923987 0.0401164
t cells 3 Immunophenotyping Immunology -0.1338701 -0.2750284 0.0072883 0.0326594 -0.1240786 -0.4120104 0.1638531 0.0668611 -0.0005749 -0.1663201 0.1651702 0.0374233
12khz-evoked abr threshold 1 Auditory Brain Stem Response Hearing 0.0538655 -0.0056830 0.1134139 0.0303824 0.0869649 0.0065802 0.1673497 0.0410134 0.0024851 -0.0214504 0.0264205 0.0122122
18khz-evoked abr threshold 1 Auditory Brain Stem Response Hearing 0.0238241 -0.0331809 0.0808292 0.0290848 0.0250266 -0.0488450 0.0988982 0.0376903 -0.0200763 -0.0431508 0.0029982 0.0117729
24khz-evoked abr threshold 1 Auditory Brain Stem Response Hearing 0.0518127 -0.0148242 0.1184497 0.0339991 -0.0891510 -0.3321998 0.1538977 0.1240067 -0.0224536 -0.0444163 -0.0004910 0.0112057
30khz-evoked abr threshold 1 Auditory Brain Stem Response Hearing 0.0170933 -0.0533187 0.0875053 0.0359252 -0.0344797 -0.1017901 0.0328306 0.0343426 -0.0497874 -0.0748197 -0.0247550 0.0127718
6khz-evoked abr threshold 1 Auditory Brain Stem Response Hearing -0.0077678 -0.0418582 0.0263226 0.0173934 0.0141682 -0.0189973 0.0473337 0.0169215 0.0184043 0.0056897 0.0311189 0.0064872
alanine aminotransferase 1 Clinical Chemistry Physiology -0.0684217 -0.1895020 0.0526586 0.0617768 0.0585179 -0.1322507 0.2492866 0.0973327 0.1069442 0.0319934 0.1818950 0.0382409
albumin 1 Clinical Chemistry Physiology 0.1133080 0.0451475 0.1814685 0.0347764 0.0559995 -0.0080678 0.1200668 0.0326880 -0.0567840 -0.0732083 -0.0403597 0.0083799
alkaline phosphatase 1 Clinical Chemistry Physiology 0.1043649 0.0451585 0.1635713 0.0302079 -0.3112471 -0.3980164 -0.2244778 0.0442709 -0.4216032 -0.4694832 -0.3737231 0.0244290
alpha-amylase 1 Clinical Chemistry Physiology 0.0383407 -0.0423419 0.1190232 0.0411653 0.2795566 0.1615777 0.3975355 0.0601944 0.2246987 0.1793151 0.2700822 0.0231553
area under glucose response curve 1 Intraperitoneal glucose tolerance test (IPGTT) Metabolism -0.1531723 -0.2210551 -0.0852895 0.0346347 0.2748396 0.1950895 0.3545898 0.0406896 0.4357738 0.3655882 0.5059595 0.0358097
aspartate aminotransferase 1 Clinical Chemistry Physiology 0.0119165 -0.1228287 0.1466617 0.0687488 -0.0566968 -0.2457779 0.1323843 0.0964717 -0.0585577 -0.1331777 0.0160624 0.0380722
basophil cell count 1 Hematology Hematology -0.0917931 -0.2022487 0.0186624 0.0563559 0.2031265 -0.0131549 0.4194079 0.1103497 0.2675772 0.0643028 0.4708516 0.1037133
basophil differential count 1 Hematology Hematology -0.0934739 -0.1787512 -0.0081966 0.0435096 -0.0639511 -0.2828066 0.1549044 0.1116630 -0.0156339 -0.1102310 0.0789633 0.0482647
bmc/body weight 1 Body Composition (DEXA lean/fat) Morphology 0.1314998 0.0329846 0.2300151 0.0502638 -0.0448684 -0.1340146 0.0442777 0.0454836 -0.1722378 -0.2207030 -0.1237726 0.0247276
body length 1 Body Composition (DEXA lean/fat) Morphology -0.0347988 -0.0824528 0.0128552 0.0243137 -0.0059677 -0.0526221 0.0406866 0.0238037 0.0282722 0.0233254 0.0332189 0.0025239
body temp 1 Echo Heart -0.0325368 -0.1066429 0.0415693 0.0378099 -0.0303742 -0.1044537 0.0437054 0.0377964 0.0018532 -0.0005002 0.0042066 0.0012008
body weight 1 Body Weight Morphology 0.0245675 -0.0420402 0.0911752 0.0339841 0.2335793 0.1694979 0.2976607 0.0326952 0.2096770 0.1938727 0.2254813 0.0080636
body weight after experiment 1 Indirect Calorimetry Metabolism 0.0853708 0.0299665 0.1407751 0.0282680 0.2849370 0.2328875 0.3369866 0.0265564 0.2030973 0.1864076 0.2197871 0.0085153
body weight before experiment 1 Indirect Calorimetry Metabolism 0.1053511 0.0412461 0.1694562 0.0327073 0.3038998 0.2435428 0.3642568 0.0307949 0.2008638 0.1816362 0.2200914 0.0098102
bone area 1 Body Composition (DEXA lean/fat) Morphology 0.0981587 0.0272824 0.1690349 0.0361620 0.1286546 0.0533659 0.2039432 0.0384133 0.0315241 0.0003806 0.0626676 0.0158898
bone mineral content (excluding skull) 1 Body Composition (DEXA lean/fat) Morphology 0.1709230 0.0625642 0.2792818 0.0552861 0.2091372 0.1015600 0.3167143 0.0548873 0.0372537 -0.0130828 0.0875902 0.0256824
bone mineral density (excluding skull) 1 Body Composition (DEXA lean/fat) Morphology 0.0542638 -0.0881612 0.1966887 0.0726671 0.0492830 -0.1087868 0.2073528 0.0806494 0.0012286 -0.0187942 0.0212514 0.0102159
calcium 1 Clinical Chemistry Physiology 0.0097946 -0.0464600 0.0660492 0.0287018 0.0135683 -0.0424600 0.0695966 0.0285864 0.0036564 -0.0000609 0.0073737 0.0018966
cardiac output 1 Echo Heart 0.0133816 -0.0797535 0.1065166 0.0475188 0.1017991 0.0206287 0.1829694 0.0414142 0.0934439 0.0580233 0.1288645 0.0180721
center average speed 1 Open Field Behaviour 0.0167300 -0.0404735 0.0739335 0.0291860 -0.0588515 -0.1004209 -0.0172820 0.0212093 -0.0724619 -0.1149622 -0.0299616 0.0216842
center distance travelled 1 Open Field Behaviour -0.0162603 -0.0733243 0.0408038 0.0291149 -0.1060637 -0.2023343 -0.0097930 0.0491186 -0.0940204 -0.1945774 0.0065366 0.0513055
center permanence time 1 Open Field Behaviour -0.0253715 -0.0826435 0.0319004 0.0292209 -0.0255734 -0.1014389 0.0502922 0.0387076 -0.0035151 -0.0902886 0.0832585 0.0442730
center resting time 1 Open Field Behaviour 0.0244492 -0.0737922 0.1226906 0.0501241 -0.0228690 -0.1548339 0.1090960 0.0673303 -0.0630751 -0.2215457 0.0953955 0.0808538
chloride 1 Clinical Chemistry Physiology 0.0321555 -0.1270972 0.1914083 0.0812529 0.0241491 -0.1438502 0.1921485 0.0857155 -0.0127047 -0.0177349 -0.0076745 0.0025665
click-evoked abr threshold 1 Auditory Brain Stem Response Hearing -0.0529450 -0.1534816 0.0475915 0.0512951 -0.0561198 -0.1827679 0.0705282 0.0646176 -0.0154221 -0.0577200 0.0268757 0.0215809
creatine kinase 1 Clinical Chemistry Physiology 0.0241232 -0.1071457 0.1553920 0.0669751 -0.1318792 -0.3968974 0.1331390 0.1352159 -0.1344413 -0.3838303 0.1149476 0.1272416
creatinine 1 Clinical Chemistry Physiology 0.0352315 -0.0229205 0.0933835 0.0296699 0.1066373 -0.2200831 0.4333578 0.1666972 -0.0844078 -0.1320251 -0.0367905 0.0242950
cv 1 Electrocardiogram (ECG) Heart 0.1874544 0.0716631 0.3032457 0.0590783 -0.0895722 -0.2484833 0.0693388 0.0810786 -0.2401301 -0.3410322 -0.1392280 0.0514816
distance travelled - total 1 Open Field Behaviour -0.0187819 -0.0858957 0.0483318 0.0342423 -0.1272582 -0.1997426 -0.0547738 0.0369825 -0.1121373 -0.1816322 -0.0426424 0.0354572
ejection fraction 1 Echo Heart -0.0300111 -0.1345066 0.0744844 0.0533150 -0.0525735 -0.1483174 0.0431705 0.0488499 -0.0284086 -0.0492579 -0.0075592 0.0106376
end-diastolic diameter 1 Echo Heart 0.1120972 0.0431489 0.1810454 0.0351783 0.1743929 0.0875252 0.2612607 0.0443211 0.0600907 0.0354923 0.0846891 0.0125504
end-systolic diameter 1 Echo Heart -0.0084176 -0.0780811 0.0612459 0.0355433 0.0668966 -0.0016692 0.1354624 0.0349832 0.0763195 0.0451136 0.1075254 0.0159217
fasted blood glucose concentration 1 Intraperitoneal glucose tolerance test (IPGTT) Metabolism -0.0177245 -0.1256855 0.0902366 0.0550832 0.0702824 -0.0302439 0.1708087 0.0512899 0.0868420 0.0493007 0.1243832 0.0191541
fat mass 1 Body Composition (DEXA lean/fat) Morphology 0.0408799 -0.0430149 0.1247746 0.0428042 0.3714313 0.2698790 0.4729837 0.0518134 0.3282080 0.2669032 0.3895129 0.0312786
fat/body weight 1 Body Composition (DEXA lean/fat) Morphology 0.0777327 -0.0119735 0.1674390 0.0457693 0.2020776 0.1083557 0.2957996 0.0478182 0.1235292 0.0638629 0.1831955 0.0304425
forelimb and hindlimb grip strength measurement mean 1 Grip Strength Morphology 0.0578158 0.0039998 0.1116318 0.0274577 0.1145986 0.0530521 0.1761451 0.0314018 0.0541888 0.0294838 0.0788938 0.0126048
forelimb grip strength measurement mean 1 Grip Strength Morphology 0.0265051 -0.0187240 0.0717341 0.0230765 0.0995076 0.0539740 0.1450413 0.0232319 0.0697061 0.0438625 0.0955496 0.0131857
fractional shortening 1 Echo Heart -0.0148852 -0.1161666 0.0863961 0.0516751 -0.0575326 -0.1558559 0.0407907 0.0501659 -0.0413498 -0.0567105 -0.0259891 0.0078372
free fatty acids 1 Clinical Chemistry Physiology 0.0281576 -0.1002531 0.1565683 0.0655169 0.0554109 -0.0736861 0.1845079 0.0658670 0.0193783 -0.0093700 0.0481266 0.0146678
fructosamine 1 Clinical Chemistry Physiology -0.0397864 -0.1198801 0.0403073 0.0408649 -0.0678231 -0.1513538 0.0157075 0.0426184 -0.0283579 -0.0692447 0.0125289 0.0208610
glucose 1 Clinical Chemistry Physiology 0.0692601 0.0184025 0.1201176 0.0259482 0.1279473 0.0423001 0.2135946 0.0436984 0.0650887 0.0218496 0.1083279 0.0220612
hdl-cholesterol 1 Clinical Chemistry Physiology -0.0650177 -0.1255786 -0.0044568 0.0308990 0.1724354 0.0701062 0.2747646 0.0522097 0.2606961 0.2180421 0.3033501 0.0217626
heart weight 1 Heart Weight Morphology 0.1766832 0.0672843 0.2860820 0.0558168 0.3651806 0.2169840 0.5133772 0.0756119 0.1737615 0.1409037 0.2066193 0.0167645
heart weight normalised against body weight 1 Heart Weight Morphology 0.0794303 -0.0060591 0.1649198 0.0436179 0.0355574 -0.0973272 0.1684419 0.0677995 -0.0495578 -0.0835809 -0.0155346 0.0173591
hematocrit 1 Hematology Hematology 0.0566356 -0.0516862 0.1649575 0.0552673 0.0737071 -0.0328632 0.1802774 0.0543736 0.0173967 0.0035179 0.0312754 0.0070811
hemoglobin 1 Hematology Hematology 0.0867000 0.0269936 0.1464064 0.0304630 0.0867345 0.0194022 0.1540668 0.0343538 0.0051992 -0.0080216 0.0184199 0.0067454
hr 1 Electrocardiogram (ECG) Heart -0.0634490 -0.1734699 0.0465718 0.0561341 -0.0140315 -0.1488474 0.1207843 0.0687849 0.0406617 -0.0139214 0.0952448 0.0278490
hrv 1 Electrocardiogram (ECG) Heart 0.1722593 0.1094294 0.2350892 0.0320567 -0.0813225 -0.2125462 0.0499011 0.0669521 -0.2504990 -0.3657436 -0.1352545 0.0587993
initial response to glucose challenge 1 Intraperitoneal glucose tolerance test (IPGTT) Metabolism -0.0968821 -0.1503780 -0.0433861 0.0272943 0.0429971 0.0141807 0.0718136 0.0147026 0.1183626 0.0853242 0.1514009 0.0168566
insulin 1 Insulin Blood Level Metabolism -0.0993292 -0.3721975 0.1735391 0.1392211 0.1774003 -0.1938091 0.5486096 0.1893960 0.4445455 0.0944498 0.7946412 0.1786236
iron 1 Clinical Chemistry Physiology -0.0974214 -0.2141737 0.0193310 0.0595686 -0.2534898 -0.3963648 -0.1106147 0.0728968 -0.1527977 -0.1930307 -0.1125646 0.0205274
lactate dehydrogenase 1 Clinical Chemistry Physiology 0.0941249 -0.0214022 0.2096519 0.0589435 0.1409270 -0.0620594 0.3439133 0.1035664 0.0318801 -0.1412218 0.2049819 0.0883189
latency to center entry 1 Open Field Behaviour 0.1254239 0.0330185 0.2178293 0.0471465 0.3641221 0.2056000 0.5226441 0.0808801 0.2734519 0.0739366 0.4729672 0.1017954
ldl-cholesterol 1 Clinical Chemistry Physiology 0.4231644 0.1551776 0.6911512 0.1367305 0.2669283 -0.0956833 0.6295400 0.1850093 -0.1615499 -0.6010478 0.2779480 0.2242378
lean mass 1 Body Composition (DEXA lean/fat) Morphology 0.1435756 0.0759342 0.2112170 0.0345115 0.3382447 0.2664863 0.4100031 0.0366121 0.1928945 0.1752425 0.2105465 0.0090063
lean/body weight 1 Body Composition (DEXA lean/fat) Morphology 0.1953833 0.0912480 0.2995186 0.0531312 0.1840786 0.0863764 0.2817807 0.0498490 -0.0122785 -0.0257504 0.0011934 0.0068736
left anterior chamber depth 1 Eye Morphology Eye -0.1854856 -0.4305058 0.0595347 0.1250126 -0.1534983 -0.4007283 0.0937316 0.1261401 0.0331746 0.0284172 0.0379321 0.0024273
left corneal thickness 1 Eye Morphology Eye -0.1446634 -0.2339950 -0.0553319 0.0455782 -0.1352252 -0.2234178 -0.0470327 0.0449970 0.0075283 -0.0057082 0.0207648 0.0067535
left inner nuclear layer 1 Eye Morphology Eye 0.0480458 -0.0360706 0.1321622 0.0429173 0.0487217 -0.0347622 0.1322057 0.0425946 0.0006956 -0.0095012 0.0108923 0.0052025
left outer nuclear layer 1 Eye Morphology Eye -0.0675012 -0.1511666 0.0161641 0.0426872 -0.0618025 -0.1452865 0.0216814 0.0425946 0.0063811 0.0011702 0.0115921 0.0026587
left posterior chamber depth 1 Eye Morphology Eye -0.2631046 -0.4734756 -0.0527336 0.1073341 -0.2687360 -0.4790035 -0.0584686 0.1072813 -0.0026027 -0.0146655 0.0094600 0.0061546
left total retinal thickness 1 Eye Morphology Eye -0.1975770 -0.4386627 0.0435087 0.1230052 -0.1932648 -0.4269751 0.0404456 0.1192422 0.0027995 -0.0034907 0.0090898 0.0032094
locomotor activity 1 Combined SHIRPA and Dysmorphology Behaviour 0.0960106 0.0224214 0.1695997 0.0375462 -0.0159064 -0.0579694 0.0261566 0.0214611 -0.1105803 -0.1761043 -0.0450562 0.0334313
lvawd 1 Echo Heart 0.0228924 -0.0247048 0.0704896 0.0242847 0.0454075 -0.0013249 0.0921399 0.0238435 0.0246614 0.0114095 0.0379132 0.0067613
lvaws 1 Echo Heart -0.0017749 -0.2517581 0.2482083 0.1275448 0.0232601 -0.1776617 0.2241819 0.1025130 0.0112569 -0.0306073 0.0531211 0.0213597
lvidd 1 Echo Heart 0.0453256 -0.0241892 0.1148405 0.0354674 0.0981450 0.0208146 0.1754754 0.0394550 0.0528053 0.0378669 0.0677436 0.0076218
lvids 1 Echo Heart -0.0635228 -0.1990947 0.0720491 0.0691706 0.0083352 -0.1335894 0.1502598 0.0724118 0.0756177 0.0525777 0.0986576 0.0117553
lvpwd 1 Echo Heart -0.0317376 -0.1258062 0.0623311 0.0479951 -0.0104248 -0.1271922 0.1063426 0.0595763 0.0302674 0.0131900 0.0473448 0.0087131
lvpws 1 Echo Heart -0.0190522 -0.1014670 0.0633627 0.0420492 0.0089592 -0.0823356 0.1002540 0.0465798 0.0268487 0.0063146 0.0473828 0.0104768
magnesium 1 Urinalysis Physiology 0.0161699 -0.0231196 0.0554593 0.0200460 -0.0513056 -0.1167021 0.0140909 0.0333662 -0.0413354 -0.1135580 0.0308871 0.0368489
mean cell hemoglobin concentration 1 Hematology Hematology 0.0378015 -0.0880637 0.1636666 0.0642181 0.0253063 -0.1086076 0.1592202 0.0683247 -0.0113450 -0.0150702 -0.0076199 0.0019006
mean cell volume 1 Hematology Hematology 0.0039175 -0.0957495 0.1035845 0.0508514 -0.0030447 -0.0961742 0.0900848 0.0475159 -0.0063502 -0.0099649 -0.0027355 0.0018443
mean corpuscular hemoglobin 1 Hematology Hematology -0.0025833 -0.0653065 0.0601398 0.0320022 -0.0193465 -0.0824670 0.0437741 0.0322049 -0.0169768 -0.0197231 -0.0142305 0.0014012
mean platelet volume 1 Hematology Hematology 0.0487366 -0.0044688 0.1019419 0.0271461 0.0353913 -0.0210323 0.0918150 0.0287881 -0.0174066 -0.0276044 -0.0072089 0.0052030
mean r amplitude 1 Electrocardiogram (ECG) Heart 0.0084703 -0.0282092 0.0451499 0.0187144 -0.0948208 -0.1630495 -0.0265922 0.0348112 -0.0835612 -0.1503108 -0.0168116 0.0340565
mean sr amplitude 1 Electrocardiogram (ECG) Heart 0.0284617 -0.0131943 0.0701178 0.0212535 -0.0876811 -0.1270777 -0.0482845 0.0201007 -0.1130259 -0.1558048 -0.0702470 0.0218264
number of center entries 1 Open Field Behaviour 0.0150703 -0.0534907 0.0836313 0.0349807 -0.0361259 -0.0952472 0.0229955 0.0301645 -0.0588092 -0.1679907 0.0503723 0.0557059
number of rears - total 1 Open Field Behaviour -0.0011326 -0.1141113 0.1118461 0.0576432 0.1869490 -0.0392422 0.4131402 0.1154058 0.1794328 0.0568682 0.3019974 0.0625341
others 1 Immunophenotyping Immunology -0.1684902 -0.2596648 -0.0773156 0.0465185 -0.1515195 -0.2435956 -0.0594434 0.0469785 0.0196158 0.0049349 0.0342967 0.0074904
pdcs 1 Immunophenotyping Immunology -0.1732553 -0.4003845 0.0538738 0.1158844 -0.2572491 -0.7186201 0.2041219 0.2353977 -0.0915619 -0.2522236 0.0690997 0.0819717
percentage center time 1 Open Field Behaviour -0.0219679 -0.0863184 0.0423826 0.0328325 -0.0188907 -0.0912088 0.0534274 0.0368977 -0.0061802 -0.0972542 0.0848938 0.0464672
periphery average speed 1 Open Field Behaviour -0.0444272 -0.1082870 0.0194327 0.0325822 -0.1401304 -0.2117709 -0.0684898 0.0365520 -0.0963838 -0.1446043 -0.0481633 0.0246028
periphery distance travelled 1 Open Field Behaviour -0.0313217 -0.0918314 0.0291879 0.0308728 -0.1342236 -0.1874097 -0.0810376 0.0271362 -0.1037239 -0.1714836 -0.0359643 0.0345719
periphery permanence time 1 Open Field Behaviour -0.0369177 -0.1277076 0.0538721 0.0463222 -0.0294978 -0.1006346 0.0416390 0.0362950 0.0077038 -0.0137850 0.0291927 0.0109639
periphery resting time 1 Open Field Behaviour -0.0536346 -0.1266045 0.0193353 0.0372302 -0.0572459 -0.1071515 -0.0073404 0.0254625 0.0026007 -0.0558538 0.0610552 0.0298243
phosphorus 1 Clinical Chemistry Physiology -0.0485897 -0.0839101 -0.0132693 0.0180209 -0.0826120 -0.1576473 -0.0075767 0.0382840 -0.0420616 -0.0813582 -0.0027650 0.0200497
platelet count 1 Hematology Hematology 0.0737198 0.0205862 0.1268534 0.0271095 0.2415135 0.1865330 0.2964940 0.0280518 0.1642192 0.1369820 0.1914563 0.0138968
pnn5(6>ms) 1 Electrocardiogram (ECG) Heart 0.2906905 0.1716202 0.4097607 0.0607512 -0.2926013 -0.5272121 -0.0579905 0.1197016 -0.6004767 -0.9244113 -0.2765420 0.1652758
potassium 1 Clinical Chemistry Physiology -0.0705522 -0.2214989 0.0803945 0.0770150 -0.0074675 -0.1729366 0.1580015 0.0844245 0.0704162 0.0476647 0.0931676 0.0116081
pq 1 Electrocardiogram (ECG) Heart -0.0650960 -0.1538776 0.0236857 0.0452976 -0.0648322 -0.1270688 -0.0025955 0.0317540 0.0015656 -0.0259865 0.0291178 0.0140575
pr 1 Electrocardiogram (ECG) Heart -0.0564860 -0.1048371 -0.0081349 0.0246694 -0.0754718 -0.1235224 -0.0274213 0.0245160 -0.0183785 -0.0319887 -0.0047684 0.0069441
qrs 1 Electrocardiogram (ECG) Heart 0.0725454 0.0354722 0.1096185 0.0189152 0.0681074 0.0300869 0.1061278 0.0193986 -0.0054233 -0.0154885 0.0046418 0.0051354
qtc 1 Electrocardiogram (ECG) Heart 0.0328106 -0.0101032 0.0757244 0.0218952 0.0310473 -0.0207365 0.0828310 0.0264208 -0.0005046 -0.0085696 0.0075604 0.0041149
qtc dispersion 1 Electrocardiogram (ECG) Heart 0.0031258 -0.0523919 0.0586435 0.0283259 -0.0046501 -0.1060530 0.0967528 0.0517371 -0.0077373 -0.0510162 0.0355416 0.0220815
red blood cell count 1 Hematology Hematology 0.0773455 0.0071933 0.1474977 0.0357926 0.0997278 0.0316996 0.1677560 0.0347089 0.0228493 0.0088583 0.0368404 0.0071384
red blood cell distribution width 1 Hematology Hematology 0.1248464 -0.0035148 0.2532076 0.0654916 0.1353460 -0.0035862 0.2742782 0.0708851 0.0104789 -0.0032056 0.0241635 0.0069821
respiration rate 1 Echo Heart -0.1384843 -0.2178736 -0.0590950 0.0405055 -0.0703570 -0.1795875 0.0388735 0.0557309 0.0611034 0.0227141 0.0994926 0.0195867
respiratory exchange ratio 1 Indirect Calorimetry Metabolism -0.0116565 -0.0896490 0.0663361 0.0397928 -0.0106530 -0.0878483 0.0665424 0.0393861 0.0017027 -0.0057348 0.0091402 0.0037947
right anterior chamber depth 1 Eye Morphology Eye -0.4491432 -1.3293546 0.4310682 0.4490957 -0.4157377 -1.2918620 0.4603867 0.4470104 0.0316098 0.0264512 0.0367685 0.0026320
right corneal thickness 1 Eye Morphology Eye -0.0355898 -0.2280522 0.1568726 0.0981969 -0.0306550 -0.1963692 0.1350592 0.0845496 -0.0013855 -0.0237830 0.0210121 0.0114275
right inner nuclear layer 1 Eye Morphology Eye -0.2545083 -0.7633116 0.2542949 0.2595983 -0.2785114 -0.8373133 0.2802906 0.2851083 -0.0175090 -0.0664158 0.0313978 0.0249529
right outer nuclear layer 1 Eye Morphology Eye 0.0061253 -0.0781241 0.0903746 0.0429851 0.0109098 -0.0731427 0.0949622 0.0428847 0.0055513 0.0000519 0.0110508 0.0028059
right posterior chamber depth 1 Eye Morphology Eye -0.0775673 -0.2905688 0.1354341 0.1086762 -0.0764571 -0.2893152 0.1364010 0.1086031 0.0071990 -0.0178434 0.0322413 0.0127769
right total retinal thickness 1 Eye Morphology Eye -0.1987993 -0.6457320 0.2481333 0.2280310 -0.1925482 -0.6285715 0.2434750 0.2224649 0.0052882 -0.0045957 0.0151720 0.0050429
rmssd 1 Electrocardiogram (ECG) Heart 0.1800273 -0.0882317 0.4482864 0.1368694 -0.0161048 -0.4112809 0.3790712 0.2016241 -0.1178703 -0.2449843 0.0092436 0.0648552
rp macrophage (cd19- cd11c-) 1 Immunophenotyping Immunology -0.0765771 -0.3398075 0.1866533 0.1343037 -0.0747691 -0.3351316 0.1855933 0.1328404 -0.0746396 -0.2072980 0.0580188 0.0676841
rr 1 Electrocardiogram (ECG) Heart -0.0761505 -0.1876687 0.0353678 0.0568981 -0.0896869 -0.2063458 0.0269721 0.0595210 -0.0125023 -0.0214082 -0.0035963 0.0045440
sodium 1 Clinical Chemistry Physiology 0.0262100 -0.1171674 0.1695873 0.0731531 0.0338228 -0.1337162 0.2013618 0.0854806 0.0099680 0.0065815 0.0133545 0.0017278
spleen weight 1 Immunophenotyping Immunology 0.1874259 -0.0500875 0.4249393 0.1211825 0.1133706 -0.1604807 0.3872220 0.1397227 -0.1542349 -0.2104415 -0.0980283 0.0286774
st 1 Electrocardiogram (ECG) Heart 0.0032888 -0.0544512 0.0610288 0.0294597 -0.0054976 -0.0811810 0.0701858 0.0386147 -0.0034902 -0.0175917 0.0106113 0.0071948
stroke volume 1 Echo Heart 0.0594276 -0.0782445 0.1970997 0.0702422 0.1574330 0.0091891 0.3056769 0.0756360 0.0937375 0.0775587 0.1099162 0.0082546
tibia length 1 Heart Weight Morphology -0.1475403 -0.4396127 0.1445320 0.1490192 -0.1374401 -0.4261352 0.1512551 0.1472961 0.0095199 0.0059199 0.0131200 0.0018368
total bilirubin 1 Clinical Chemistry Physiology 0.0605449 -0.0097669 0.1308567 0.0358740 0.0022671 -0.0859910 0.0905252 0.0450305 -0.0550333 -0.0979518 -0.0121148 0.0218976
total cholesterol 1 Clinical Chemistry Physiology 0.0942595 -0.0751596 0.2636786 0.0864399 0.3142208 0.1125613 0.5158803 0.1028894 0.2027583 0.1750477 0.2304688 0.0141383
total food intake 1 Indirect Calorimetry Metabolism -0.1192293 -0.2542902 0.0158316 0.0689099 -0.0964842 -0.2564912 0.0635228 0.0816377 0.0267691 -0.0233285 0.0768667 0.0255605
total protein 1 Clinical Chemistry Physiology -0.0422347 -0.0623878 -0.0220816 0.0102824 -0.0355909 -0.0619127 -0.0092692 0.0134297 0.0092660 -0.0008158 0.0193478 0.0051439
total water intake 1 Indirect Calorimetry Metabolism -0.1457383 -0.2373165 -0.0541601 0.0467244 -0.2097443 -0.2681948 -0.1512937 0.0298223 -0.0654284 -0.1374220 0.0065653 0.0367321
triglycerides 1 Clinical Chemistry Physiology -0.0320020 -0.1233659 0.0593619 0.0466151 0.3268957 0.2087111 0.4450803 0.0602994 0.3473552 0.2592006 0.4355098 0.0449777
urea (blood urea nitrogen - bun) 1 Clinical Chemistry Physiology -0.1405306 -0.2664120 -0.0146491 0.0642264 -0.0950040 -0.2507897 0.0607817 0.0794840 0.0403162 0.0051883 0.0754441 0.0179227
uric acid 1 Clinical Chemistry Physiology 0.0367062 -0.0660619 0.1394744 0.0524337 0.3626957 0.0914512 0.6339402 0.1383926 0.4472349 -0.0801891 0.9746588 0.2690988
white blood cell count 1 Hematology Hematology -0.0907957 -0.1703063 -0.0112852 0.0405673 0.1168446 -0.0023934 0.2360826 0.0608368 0.1978876 0.1368305 0.2589447 0.0311521
whole arena average speed 1 Open Field Behaviour -0.0156634 -0.0857564 0.0544296 0.0357624 -0.1140149 -0.1840029 -0.0440269 0.0357088 -0.0997437 -0.1519566 -0.0475307 0.0266397
whole arena resting time 1 Open Field Behaviour -0.0531307 -0.1011672 -0.0050941 0.0245089 -0.0593672 -0.1076067 -0.0111276 0.0246125 0.0045878 -0.0513396 0.0605152 0.0285349
# trait_meta_results <- write.csv(metacombo, file =
# 'export/trait_meta_results.csv') #Felix 7/2/2020: I think this can be
# deleted for publication!

3. Second-order meta-analysis for functional groups

(Section H in Figure 3 in main article)

Performing meta-analyses (3 for each of the 9 grouping terms: lnCVR, lnVR, lnRR)

Preparation of data

Nesting, calculating the number of parameters within each grouping term, and running the meta-analyses

metacombo_final <- metacombo %>% group_by(GroupingTerm) %>% nest()

# **calculate number of parameters per grouping term

metacombo_final <- metacombo_final %>% mutate(para_per_GroupingTerm = map_dbl(data, 
    nrow))

# For all grouping terms
metacombo_final_all <- metacombo %>% nest(data = everything())


# **Final fixed effects meta-analyses within grouping terms, with SE of the
# estimate

overall1 <- metacombo_final %>% 
mutate(model_lnCVR = map(data, ~metafor::rma.uni(yi = .x$lnCVR, sei = (.x$lnCVR_upper - 
    .x$lnCVR_lower)/(2 * 1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
    maxit = 1000), verbose = F)), model_lnVR = map(data, ~metafor::rma.uni(yi = .x$lnVR, 
    sei = (.x$lnVR_upper - .x$lnVR_lower)/(2 * 1.96), control = list(optimizer = "optim", 
        optmethod = "Nelder-Mead", maxit = 1000), verbose = F)), model_lnRR = map(data, 
    ~metafor::rma.uni(yi = .x$lnRR, sei = (.x$lnRR_upper - .x$lnRR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

# **Final fixed effects meta-analyses ACROSS grouping terms, with SE of the
# estimate

overall_all1 <- metacombo_final_all %>% 
mutate(model_lnCVR = map(data, ~metafor::rma.uni(yi = .x$lnCVR, sei = (.x$lnCVR_upper - 
    .x$lnCVR_lower)/(2 * 1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
    maxit = 1000), verbose = F)), model_lnVR = map(data, ~metafor::rma.uni(yi = .x$lnVR, 
    sei = (.x$lnVR_upper - .x$lnVR_lower)/(2 * 1.96), control = list(optimizer = "optim", 
        optmethod = "Nelder-Mead", maxit = 1000), verbose = F)), model_lnRR = map(data, 
    ~metafor::rma.uni(yi = .x$lnRR, sei = (.x$lnRR_upper - .x$lnRR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

Re-structuring the data for each grouping term

We here delete unused variables, and select the respective effect sizes. Please note - the referencing of the cells does NOT depend on previous ordering of the data. This would only be affected if the output structure from metafor::rma.uni changes.

Behaviour <- overall1 %>% filter(., GroupingTerm == "Behaviour") %>% mutate(lnCVR = .[[4]][[1]]$b, 
    lnCVR_lower = .[[4]][[1]]$ci.lb, lnCVR_upper = .[[4]][[1]]$ci.ub, lnCVR_se = .[[4]][[1]]$se, 
    lnVR = .[[5]][[1]]$b, lnVR_lower = .[[5]][[1]]$ci.lb, lnVR_upper = .[[5]][[1]]$ci.ub, 
    lnVR_se = .[[5]][[1]]$se, lnRR = .[[6]][[1]]$b, lnRR_lower = .[[6]][[1]]$ci.lb, 
    lnRR_upper = .[[6]][[1]]$ci.ub, lnRR_se = .[[6]][[1]]$se) %>% select(., 
    GroupingTerm, lnCVR:lnRR_se)

Immunology <- overall1 %>% filter(., GroupingTerm == "Immunology") %>% mutate(lnCVR = .[[4]][[1]]$b, 
    lnCVR_lower = .[[4]][[1]]$ci.lb, lnCVR_upper = .[[4]][[1]]$ci.ub, lnCVR_se = .[[4]][[1]]$se, 
    lnVR = .[[5]][[1]]$b, lnVR_lower = .[[5]][[1]]$ci.lb, lnVR_upper = .[[5]][[1]]$ci.ub, 
    lnVR_se = .[[5]][[1]]$se, lnRR = .[[6]][[1]]$b, lnRR_lower = .[[6]][[1]]$ci.lb, 
    lnRR_upper = .[[6]][[1]]$ci.ub, lnRR_se = .[[6]][[1]]$se) %>% select(., 
    GroupingTerm, lnCVR:lnRR_se)

Hematology <- overall1 %>% filter(., GroupingTerm == "Hematology") %>% mutate(lnCVR = .[[4]][[1]]$b, 
    lnCVR_lower = .[[4]][[1]]$ci.lb, lnCVR_upper = .[[4]][[1]]$ci.ub, lnCVR_se = .[[4]][[1]]$se, 
    lnVR = .[[5]][[1]]$b, lnVR_lower = .[[5]][[1]]$ci.lb, lnVR_upper = .[[5]][[1]]$ci.ub, 
    lnVR_se = .[[5]][[1]]$se, lnRR = .[[6]][[1]]$b, lnRR_lower = .[[6]][[1]]$ci.lb, 
    lnRR_upper = .[[6]][[1]]$ci.ub, lnRR_se = .[[6]][[1]]$se) %>% select(., 
    GroupingTerm, lnCVR:lnRR_se)

Hearing <- overall1 %>% filter(., GroupingTerm == "Hearing") %>% mutate(lnCVR = .[[4]][[1]]$b, 
    lnCVR_lower = .[[4]][[1]]$ci.lb, lnCVR_upper = .[[4]][[1]]$ci.ub, lnCVR_se = .[[4]][[1]]$se, 
    lnVR = .[[5]][[1]]$b, lnVR_lower = .[[5]][[1]]$ci.lb, lnVR_upper = .[[5]][[1]]$ci.ub, 
    lnVR_se = .[[5]][[1]]$se, lnRR = .[[6]][[1]]$b, lnRR_lower = .[[6]][[1]]$ci.lb, 
    lnRR_upper = .[[6]][[1]]$ci.ub, lnRR_se = .[[6]][[1]]$se) %>% select(., 
    GroupingTerm, lnCVR:lnRR_se)

Physiology <- overall1 %>% filter(., GroupingTerm == "Physiology") %>% mutate(lnCVR = .[[4]][[1]]$b, 
    lnCVR_lower = .[[4]][[1]]$ci.lb, lnCVR_upper = .[[4]][[1]]$ci.ub, lnCVR_se = .[[4]][[1]]$se, 
    lnVR = .[[5]][[1]]$b, lnVR_lower = .[[5]][[1]]$ci.lb, lnVR_upper = .[[5]][[1]]$ci.ub, 
    lnVR_se = .[[5]][[1]]$se, lnRR = .[[6]][[1]]$b, lnRR_lower = .[[6]][[1]]$ci.lb, 
    lnRR_upper = .[[6]][[1]]$ci.ub, lnRR_se = .[[6]][[1]]$se) %>% select(., 
    GroupingTerm, lnCVR:lnRR_se)

Metabolism <- overall1 %>% filter(., GroupingTerm == "Metabolism") %>% mutate(lnCVR = .[[4]][[1]]$b, 
    lnCVR_lower = .[[4]][[1]]$ci.lb, lnCVR_upper = .[[4]][[1]]$ci.ub, lnCVR_se = .[[4]][[1]]$se, 
    lnVR = .[[5]][[1]]$b, lnVR_lower = .[[5]][[1]]$ci.lb, lnVR_upper = .[[5]][[1]]$ci.ub, 
    lnVR_se = .[[5]][[1]]$se, lnRR = .[[6]][[1]]$b, lnRR_lower = .[[6]][[1]]$ci.lb, 
    lnRR_upper = .[[6]][[1]]$ci.ub, lnRR_se = .[[6]][[1]]$se) %>% select(., 
    GroupingTerm, lnCVR:lnRR_se)

Morphology <- overall1 %>% filter(., GroupingTerm == "Morphology") %>% mutate(lnCVR = .[[4]][[1]]$b, 
    lnCVR_lower = .[[4]][[1]]$ci.lb, lnCVR_upper = .[[4]][[1]]$ci.ub, lnCVR_se = .[[4]][[1]]$se, 
    lnVR = .[[5]][[1]]$b, lnVR_lower = .[[5]][[1]]$ci.lb, lnVR_upper = .[[5]][[1]]$ci.ub, 
    lnVR_se = .[[5]][[1]]$se, lnRR = .[[6]][[1]]$b, lnRR_lower = .[[6]][[1]]$ci.lb, 
    lnRR_upper = .[[6]][[1]]$ci.ub, lnRR_se = .[[6]][[1]]$se) %>% select(., 
    GroupingTerm, lnCVR:lnRR_se)

Heart <- overall1 %>% filter(., GroupingTerm == "Heart") %>% mutate(lnCVR = .[[4]][[1]]$b, 
    lnCVR_lower = .[[4]][[1]]$ci.lb, lnCVR_upper = .[[4]][[1]]$ci.ub, lnCVR_se = .[[4]][[1]]$se, 
    lnVR = .[[5]][[1]]$b, lnVR_lower = .[[5]][[1]]$ci.lb, lnVR_upper = .[[5]][[1]]$ci.ub, 
    lnVR_se = .[[5]][[1]]$se, lnRR = .[[6]][[1]]$b, lnRR_lower = .[[6]][[1]]$ci.lb, 
    lnRR_upper = .[[6]][[1]]$ci.ub, lnRR_se = .[[6]][[1]]$se) %>% select(., 
    GroupingTerm, lnCVR:lnRR_se)

Eye <- overall1 %>% filter(., GroupingTerm == "Eye") %>% mutate(lnCVR = .[[4]][[1]]$b, 
    lnCVR_lower = .[[4]][[1]]$ci.lb, lnCVR_upper = .[[4]][[1]]$ci.ub, lnCVR_se = .[[4]][[1]]$se, 
    lnVR = .[[5]][[1]]$b, lnVR_lower = .[[5]][[1]]$ci.lb, lnVR_upper = .[[5]][[1]]$ci.ub, 
    lnVR_se = .[[5]][[1]]$se, lnRR = .[[6]][[1]]$b, lnRR_lower = .[[6]][[1]]$ci.lb, 
    lnRR_upper = .[[6]][[1]]$ci.ub, lnRR_se = .[[6]][[1]]$se) %>% select(., 
    GroupingTerm, lnCVR:lnRR_se)

All <- overall_all1 %>% mutate(lnCVR = .[[2]][[1]]$b, lnCVR_lower = .[[2]][[1]]$ci.lb, 
    lnCVR_upper = .[[2]][[1]]$ci.ub, lnCVR_se = .[[2]][[1]]$se, lnVR = .[[3]][[1]]$b, 
    lnVR_lower = .[[3]][[1]]$ci.lb, lnVR_upper = .[[3]][[1]]$ci.ub, lnVR_se = .[[3]][[1]]$se, 
    lnRR = .[[4]][[1]]$b, lnRR_lower = .[[4]][[1]]$ci.lb, lnRR_upper = .[[4]][[1]]$ci.ub, 
    lnRR_se = .[[4]][[1]]$se) %>% select(., lnCVR:lnRR_se)

All <- All %>% mutate(GroupingTerm = "All")

overall2 <- bind_rows(Behaviour, Morphology, Metabolism, Physiology, Immunology, 
    Hematology, Heart, Hearing, Eye, All)

Visualisation

Figure 4

Preparation for plots: Count data, based on First-order metamanalysis results

This includes all separate eligible traits. Re-ordering of grouping terms

meta_clean$GroupingTerm <- factor(meta_clean$GroupingTerm, levels = c("Behaviour", 
    "Morphology", "Metabolism", "Physiology", "Immunology", "Hematology", "Heart", 
    "Hearing", "Eye"))
meta_clean$GroupingTerm <- factor(meta_clean$GroupingTerm, rev(levels(meta_clean$GroupingTerm)))

# *Preparing data for all traits

meta.plot2.all <- meta_clean %>% select(lnCVR, lnVR, lnRR, GroupingTerm) %>% 
    arrange(GroupingTerm)

meta.plot2.all.b <- gather(meta.plot2.all, trait, value, c(lnCVR, lnRR))  # lnVR has been removed here and in the steps below, as this is only included in the supplemental figure

meta.plot2.all.b$trait <- factor(meta.plot2.all.b$trait, levels = c("lnCVR", 
    "lnRR"))
meta.plot2.all.c <- meta.plot2.all.b %>% group_by_at(vars(trait, GroupingTerm)) %>% 
    summarise(malebias = sum(value > 0), femalebias = sum(value <= 0), total = malebias + 
        femalebias, malepercent = malebias * 100/total, femalepercent = femalebias * 
        100/total)

meta.plot2.all.c$label <- "All traits"

# Re-structure to create stacked bar plots

meta.plot2.all.d <- as.data.frame(meta.plot2.all.c)
meta.plot2.all.e <- gather(meta.plot2.all.d, key = sex, value = percent, malepercent:femalepercent, 
    factor_key = TRUE)

# Create new sample size variable

meta.plot2.all.e$samplesize <- with(meta.plot2.all.e, ifelse(sex == "malepercent", 
    malebias, femalebias))

# Add summary row ('All') and re-arrange rows into correct order for
# plotting (warnings about coercing 'id' into character vector are ok)

meta.plot2.all.f <- meta.plot2.all.e %>% group_by(trait, sex) %>% summarise(GroupingTerm = "All", 
    malebias = sum(malebias), femalebias = sum(femalebias), total = malebias + 
        femalebias, label = "All traits", samplesize = sum(samplesize)) %>% 
    mutate(percent = ifelse(sex == "femalepercent", femalebias * 100/(malebias + 
        femalebias), malebias * 100/(malebias + femalebias))) %>% bind_rows(meta.plot2.all.e, 
    .) %>% mutate(rownumber = row_number()) %>% .[c(37, 1:9, 39, 10:18, 38, 
    19:27, 40, 28:36), ]
# line references in previous code line corresponding to:
#'lnCVR(male(All)), lnCVR(male('single grouping terms'), lnRR(male(All)), lnRR(male('single grouping terms')),
# lnCVR(female(All)), lnCVR(female('single grouping terms'),
# lnRR(female(All)), lnRR(female('single grouping terms'))'

meta.plot2.all.f$GroupingTerm <- factor(meta.plot2.all.f$GroupingTerm, levels = c("Behaviour", 
    "Morphology", "Metabolism", "Physiology", "Immunology", "Hematology", "Heart", 
    "Hearing", "Eye", "All"))
meta.plot2.all.f$GroupingTerm <- factor(meta.plot2.all.f$GroupingTerm, rev(levels(meta.plot2.all.f$GroupingTerm)))

malebias_Fig2_alltraits <- ggplot(meta.plot2.all.f) + aes(x = GroupingTerm, 
    y = percent, fill = sex) + geom_col() + geom_hline(yintercept = 50, linetype = "dashed", 
    color = "gray40") + geom_text(data = subset(meta.plot2.all.f, samplesize != 
    0), aes(label = samplesize), position = position_stack(vjust = 0.5), color = "white", 
    size = 3.5) + facet_grid(cols = vars(trait), rows = vars(label), labeller = label_wrap_gen(width = 18), 
    scales = "free", space = "free") + scale_fill_brewer(palette = "Set2") + 
    theme_bw(base_size = 18) + theme(strip.text.y = element_text(angle = 270, 
    size = 10, margin = margin(t = 15, r = 15, b = 15, l = 15)), strip.text.x = element_text(size = 12), 
    strip.background = element_rect(colour = NULL, linetype = "blank", fill = "gray90"), 
    text = element_text(size = 14), panel.spacing = unit(0.5, "lines"), panel.border = element_blank(), 
    axis.line = element_line(), panel.grid.major.x = element_line(linetype = "solid", 
        colour = "gray95"), panel.grid.major.y = element_line(linetype = "solid", 
        color = "gray95"), panel.grid.minor.y = element_blank(), panel.grid.minor.x = element_blank(), 
    legend.position = "none", axis.title.x = element_blank(), axis.title.y = element_blank()) + 
    coord_flip()

# malebias_Fig2_alltraits #(panel A in Figure 4 in ms)

Overall results of second order meta-analysis (Figure 4, Panel B)

Re-structure data for plotting

Data are re-structured, and grouping terms are being re-ordered

overall3 <- gather(overall2, parameter, value, c(lnCVR, lnRR), factor_key = TRUE)

lnCVR.ci <- overall3 %>% filter(parameter == "lnCVR") %>% mutate(ci.low = lnCVR_lower, 
    ci.high = lnCVR_upper)
lnVR.ci <- overall3 %>% filter(parameter == "lnVR") %>% mutate(ci.low = lnVR_lower, 
    ci.high = lnVR_upper)
lnRR.ci <- overall3 %>% filter(parameter == "lnRR") %>% mutate(ci.low = lnRR_lower, 
    ci.high = lnRR_upper)

overall4 <- bind_rows(lnCVR.ci, lnRR.ci) %>% select(GroupingTerm, parameter, 
    value, ci.low, ci.high)

# Re-order grouping terms

overall4$GroupingTerm <- factor(overall4$GroupingTerm, levels = c("Behaviour", 
    "Morphology", "Metabolism", "Physiology", "Immunology", "Hematology", "Heart", 
    "Hearing", "Eye", "All"))
overall4$GroupingTerm <- factor(overall4$GroupingTerm, rev(levels(overall4$GroupingTerm)))
overall4$label <- "All traits"

kable(cbind(overall4, overall4)) %>% kable_styling() %>% scroll_box(width = "100%", 
    height = "200px")
GroupingTerm parameter value ci.low ci.high label GroupingTerm1 parameter1 value1 ci.low1 ci.high1 label1
Behaviour lnCVR -0.0035049 -0.0240688 0.0170591 All traits Behaviour lnCVR -0.0035049 -0.0240688 0.0170591 All traits
Morphology lnCVR 0.0774453 0.0414171 0.1134734 All traits Morphology lnCVR 0.0774453 0.0414171 0.1134734 All traits
Metabolism lnCVR -0.0430831 -0.1125945 0.0264283 All traits Metabolism lnCVR -0.0430831 -0.1125945 0.0264283 All traits
Physiology lnCVR 0.0126792 -0.0140094 0.0393678 All traits Physiology lnCVR 0.0126792 -0.0140094 0.0393678 All traits
Immunology lnCVR -0.0681817 -0.0980135 -0.0383499 All traits Immunology lnCVR -0.0681817 -0.0980135 -0.0383499 All traits
Hematology lnCVR 0.0217865 -0.0165045 0.0600776 All traits Hematology lnCVR 0.0217865 -0.0165045 0.0600776 All traits
Heart lnCVR 0.0183839 -0.0128375 0.0496053 All traits Heart lnCVR 0.0183839 -0.0128375 0.0496053 All traits
Hearing lnCVR 0.0157302 -0.0111999 0.0426603 All traits Hearing lnCVR 0.0157302 -0.0111999 0.0426603 All traits
Eye lnCVR -0.0817932 -0.1476821 -0.0159043 All traits Eye lnCVR -0.0817932 -0.1476821 -0.0159043 All traits
All lnCVR 0.0046553 -0.0086242 0.0179348 All traits All lnCVR 0.0046553 -0.0086242 0.0179348 All traits
Behaviour lnRR -0.0199206 -0.0634388 0.0235976 All traits Behaviour lnRR -0.0199206 -0.0634388 0.0235976 All traits
Morphology lnRR 0.0678160 0.0072225 0.1284095 All traits Morphology lnRR 0.0678160 0.0072225 0.1284095 All traits
Metabolism lnRR 0.1422577 0.0364352 0.2480801 All traits Metabolism lnRR 0.1422577 0.0364352 0.2480801 All traits
Physiology lnRR 0.0163695 -0.0443364 0.0770753 All traits Physiology lnRR 0.0163695 -0.0443364 0.0770753 All traits
Immunology lnRR -0.0574840 -0.1074213 -0.0075466 All traits Immunology lnRR -0.0574840 -0.1074213 -0.0075466 All traits
Hematology lnRR 0.0388537 -0.0024274 0.0801348 All traits Hematology lnRR 0.0388537 -0.0024274 0.0801348 All traits
Heart lnRR -0.0048933 -0.0324240 0.0226374 All traits Heart lnRR -0.0048933 -0.0324240 0.0226374 All traits
Hearing lnRR -0.0132366 -0.0335982 0.0071251 All traits Hearing lnRR -0.0132366 -0.0335982 0.0071251 All traits
Eye lnRR 0.0091186 0.0012071 0.0170302 All traits Eye lnRR 0.0091186 0.0012071 0.0170302 All traits
All lnRR 0.0124332 -0.0061474 0.0310138 All traits All lnRR 0.0124332 -0.0061474 0.0310138 All traits
Metameta_Fig3_alltraits <- overall4 %>% 
ggplot(aes(y = GroupingTerm, x = value)) + geom_errorbarh(aes(xmin = ci.low, 
    xmax = ci.high), height = 0.1, show.legend = FALSE) + geom_point(aes(shape = parameter), 
    fill = "black", color = "black", size = 2.2, show.legend = FALSE) + scale_x_continuous(limits = c(-0.24, 
    0.25), breaks = c(-0.2, -0.1, 0, 0.1, 0.2), name = "Effect size") + geom_vline(xintercept = 0, 
    color = "black", linetype = "dashed") + facet_grid(cols = vars(parameter), 
    rows = vars(label), labeller = label_wrap_gen(width = 23), scales = "free", 
    space = "free") + theme_bw() + theme(strip.text.y = element_text(angle = 270, 
    size = 10, margin = margin(t = 15, r = 15, b = 15, l = 15)), strip.text.x = element_text(size = 12), 
    strip.background = element_rect(colour = NULL, linetype = "blank", fill = "gray90"), 
    text = element_text(size = 14), panel.spacing = unit(0.5, "lines"), panel.border = element_blank(), 
    axis.line = element_line(), panel.grid.major.x = element_line(linetype = "solid", 
        colour = "gray95"), panel.grid.major.y = element_line(linetype = "solid", 
        color = "gray95"), panel.grid.minor.y = element_blank(), panel.grid.minor.x = element_blank(), 
    legend.title = element_blank(), axis.title.x = element_text(hjust = 0.5, 
        size = 14), axis.title.y = element_blank())

# Metameta_Fig3_alltraits

Fig 4 # SZ STILL TO DO

Join the different parts and #TO DO!! add M / F symbols in Metameta_Fig3_alltraits

# Test male <- readPNG(system.file('img', 'male')) test <-
# Metameta_Fig3_alltraits

# library(png)

Figure 4

Panel A shows the numbers of traits across functional groups that are either male-biased (blue-green) or female-biased (orange-red), as calculated in Step D (figure 3). Panel B shows effect sizes and 95% CI from separate meta-analysis for each functional group (step H in Figure 3). Both panels represent results evaluated across all traits (Phase 3, Figure 3). Traits that are male biased is shown in blue, whereas female bias data is represented in orange.

Fig4 <- ggarrange(malebias_Fig2_alltraits, Metameta_Fig3_alltraits, nrow = 2, 
    align = "v", heights = c(1, 1), labels = c("A", "B"))
Fig4

Figure 5

Preparing data for traits with CI not overlapping 0

To further investigate sex bias in this dataset, and in particular if the extent of sex bias differs between traits, we investigate the magnitude of male- and female bias in significantly different traits on (both for means and variability)

To do this, we select only traits that have CIs that do not overlap with zero. The code below creates Figure 5A.

meta.plot2.sig <- meta_clean %>%
  mutate(
    lnCVRsig = ifelse(lnCVR_lower * lnCVR_upper > 0, 1, 0), lnVRsig = ifelse(lnVR_lower * lnVR_upper > 0, 1, 0),
    lnRRsig = ifelse(lnRR_lower * lnRR_upper > 0, 1, 0)
  )

meta.plot2.sig.b <- meta.plot2.sig[, c("lnCVR", "lnRR", "lnCVRsig", "lnVRsig", "lnRRsig", "GroupingTerm")] 

meta.plot2.sig.c <- gather(meta.plot2.sig.b, trait, value, lnCVR:lnRR)
meta.plot2.sig.c$sig <- "placeholder"

meta.plot2.sig.c$trait <- factor(meta.plot2.sig.c$trait, levels = c("lnCVR", "lnRR")) 

meta.plot2.sig.c$sig <- ifelse(meta.plot2.sig.c$trait == "lnCVR", meta.plot2.sig.c$lnCVRsig,
  ifelse(meta.plot2.sig.c$trait == "lnVR", meta.plot2.sig.c$lnVRsig, meta.plot2.sig.c$lnRRsig)
)

# Choosing sex biased ln-ratios significantly larger than 0
meta.plot2.sig.malebias <- meta.plot2.sig.c %>%
  group_by_at(vars(trait, GroupingTerm)) %>%
  filter(sig == 1) %>%
  summarise(male_sig = sum(value > 0), female_sig = sum(value < 0), total = male_sig + female_sig)

meta.plot2.sig.malebias <- ungroup(meta.plot2.sig.malebias) %>%
  add_row(trait = "lnCVR", GroupingTerm = "Hearing", male_sig = 0, female_sig = 0, .before = 4) %>% # add "Hearing" for lnCVR (not filtered as only zeros)
  mutate(malepercent = male_sig * 100 / total, femalepercent = female_sig * 100 / total)

meta.plot2.sig.malebias$label <- "CI not overlapping zero"

# Re-structure to create stacked bar plots

meta.plot2.sig.bothsexes <- as.data.frame(meta.plot2.sig.malebias)
meta.plot2.sig.bothsexes.b <- gather(meta.plot2.sig.bothsexes, key = sex, value = percent, malepercent:femalepercent, factor_key = TRUE)

# create new sample size variable

meta.plot2.sig.bothsexes.b$samplesize <- with(meta.plot2.sig.bothsexes.b, ifelse(sex == "malepercent", male_sig, female_sig))

# Add summary row ('All') and re-arrange rows into correct order for plotting 

meta.plot2.sig.bothsexes.c <- meta.plot2.sig.bothsexes.b %>% group_by(trait, sex) %>% 
  summarise(GroupingTerm = "All", male_sig = sum(male_sig), female_sig = sum(female_sig), total = male_sig + female_sig, 
            label = "CI not overlapping zero", samplesize = sum(samplesize)) %>%
  mutate(percent = ifelse(sex == "femalepercent", female_sig*100/(male_sig+female_sig), male_sig*100/(male_sig+female_sig))) %>%
  bind_rows(meta.plot2.sig.bothsexes.b, .) %>%
  mutate(rownumber = row_number()) %>%
  .[c(37, 1:9, 39, 10:18, 38, 19:27, 40, 28:36), ] 
  #line references in previous code line corresponding to: 
  #'lnCVR(male(All)), lnCVR(male('single grouping terms'), lnRR(male(All)), lnRR(male('single grouping terms')),
  #lnCVR(female(All)), lnCVR(female('single grouping terms'), lnRR(female(All)), lnRR(female('single grouping terms'))'

meta.plot2.sig.bothsexes.c$GroupingTerm <- factor(meta.plot2.sig.bothsexes.c$GroupingTerm, levels = c("Behaviour", "Morphology", "Metabolism", "Physiology", "Immunology", "Hematology", "Heart", "Hearing", "Eye", "All")) 
meta.plot2.sig.bothsexes.c$GroupingTerm <- factor(meta.plot2.sig.bothsexes.c$GroupingTerm, rev(levels(meta.plot2.sig.bothsexes.c$GroupingTerm)))

# Plot Fig2 all significant results (CI not overlapping zero)
# Several grouping terms are added post-hoc (with no data to display): no significant lnCVR for 'Hearing' in either sex; no sig. male-biased lnCVR for 'Immunology' and 'Eye, and no significant female-biased lnRR for 'Eye'.

malebias_Fig2_sigtraits <-
  ggplot(meta.plot2.sig.bothsexes.c) +
  aes(x = GroupingTerm, y = percent, fill = sex) +
  geom_col() +
  geom_hline(yintercept = 50, linetype = "dashed", color = "gray40") +
  geom_text(
    data = subset(meta.plot2.sig.bothsexes.c, samplesize != 0), aes(label = samplesize), position = position_stack(vjust = .5),
    color = "white", size = 3.5
  ) +
  facet_grid(
    cols = vars(trait), rows = vars(label), labeller = label_wrap_gen(width = 18),
    scales = "free", space = "free"
  ) +
  scale_fill_brewer(palette = "Set2") +
  theme_bw(base_size = 18) +
  theme(
    strip.text.y = element_text(angle = 270, size = 10, margin = margin(t = 15, r = 15, b = 15, l = 15)),
    strip.text.x = element_text(size = 12),
    strip.background = element_rect(colour = NULL, linetype = "blank", fill = "gray90"),
    text = element_text(size = 14),
    panel.spacing = unit(0.5, "lines"),
    panel.border = element_blank(),
    axis.line = element_line(),
    panel.grid.major.x = element_line(linetype = "solid", colour = "gray95"),
    panel.grid.major.y = element_line(linetype = "solid", color = "gray95"),
    panel.grid.minor.y = element_blank(),
    panel.grid.minor.x = element_blank(),
    legend.position = "none",
    axis.title.x = element_blank(),
    axis.title.y = element_blank()
  ) +
  coord_flip()

Preparation for Plots on significant sex-bias (Second-order meta analysis results)

Figure 5 B - traits with CI not overlapping 0

Prepare data create column with 1= different from zero, 0= zero included in CI #### Male-biased (significant) traits

meta.male.plot3.sig <- metacombo %>% mutate(sigCVR = ifelse(lnCVR_lower > 0, 
    1, 0), sigVR = ifelse(lnVR_lower > 0, 1, 0), sigRR = ifelse(lnRR_lower > 
    0, 1, 0))

# Significant subset for lnCVR
metacombo_male.plot3.CVR <- meta.male.plot3.sig %>% filter(sigCVR == 1) %>% 
    group_by(GroupingTerm) %>% nest()

metacombo_male.plot3.CVR.all <- meta.male.plot3.sig %>% filter(sigCVR == 1) %>% 
    nest(data = everything())  #Felix added 'data = everything()' on 4/2/2020

# Significant subset for lnVR
metacombo_male.plot3.VR <- meta.male.plot3.sig %>% filter(sigVR == 1) %>% group_by(GroupingTerm) %>% 
    nest()

metacombo_male.plot3.VR.all <- meta.male.plot3.sig %>% filter(sigVR == 1) %>% 
    nest(data = everything())

# Significant subset for lnRR
metacombo_male.plot3.RR <- meta.male.plot3.sig %>% filter(sigRR == 1) %>% group_by(GroupingTerm) %>% 
    nest()

metacombo_male.plot3.RR.all <- meta.male.plot3.sig %>% filter(sigRR == 1) %>% 
    nest(data = everything())

# **Final fixed effects meta-analyses within grouping terms, with SE of the
# estimate

plot3.male.meta.CVR <- metacombo_male.plot3.CVR %>% mutate(model_lnCVR = map(data, 
    ~metafor::rma.uni(yi = .x$lnCVR, sei = (.x$lnCVR_upper - .x$lnCVR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

plot3.male.meta.VR <- metacombo_male.plot3.VR %>% mutate(model_lnVR = map(data, 
    ~metafor::rma.uni(yi = .x$lnVR, sei = (.x$lnVR_upper - .x$lnVR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

plot3.male.meta.RR <- metacombo_male.plot3.RR %>% mutate(model_lnRR = map(data, 
    ~metafor::rma.uni(yi = .x$lnRR, sei = (.x$lnRR_upper - .x$lnRR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

# Across all grouping terms #

plot3.male.meta.CVR.all <- metacombo_male.plot3.CVR.all %>% mutate(model_lnCVR = map(data, 
    ~metafor::rma.uni(yi = .x$lnCVR, sei = (.x$lnCVR_upper - .x$lnCVR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

plot3.male.meta.CVR.all <- plot3.male.meta.CVR.all %>% mutate(GroupingTerm = "All")

plot3.male.meta.VR.all <- metacombo_male.plot3.VR.all %>% mutate(model_lnVR = map(data, 
    ~metafor::rma.uni(yi = .x$lnVR, sei = (.x$lnVR_upper - .x$lnVR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

plot3.male.meta.VR.all <- plot3.male.meta.VR.all %>% mutate(GroupingTerm = "All")

plot3.male.meta.RR.all <- metacombo_male.plot3.RR.all %>% mutate(model_lnRR = map(data, 
    ~metafor::rma.uni(yi = .x$lnRR, sei = (.x$lnRR_upper - .x$lnRR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

plot3.male.meta.RR.all <- plot3.male.meta.RR.all %>% mutate(GroupingTerm = "All")

# Combine with separate grouping term results

plot3.male.meta.CVR <- bind_rows(plot3.male.meta.CVR, plot3.male.meta.CVR.all)
plot3.male.meta.VR <- bind_rows(plot3.male.meta.VR, plot3.male.meta.VR.all)
plot3.male.meta.RR <- bind_rows(plot3.male.meta.RR, plot3.male.meta.RR.all)

# **Re-structure data for each grouping term; delete un-used variables

plot3.male.meta.CVR.b <- as.data.frame(plot3.male.meta.CVR %>% group_by(GroupingTerm) %>% 
    mutate(lnCVR = map_dbl(model_lnCVR, pluck(2)), lnCVR_lower = map_dbl(model_lnCVR, 
        pluck(6)), lnCVR_upper = map_dbl(model_lnCVR, pluck(7)), lnCVR_se = map_dbl(model_lnCVR, 
        pluck(3))))[, c(1, 4:7)]
add.row.hearing <- as.data.frame(t(c("Hearing", NA, NA, NA, NA))) %>% setNames(names(plot3.male.meta.CVR.b))

plot3.male.meta.CVR.b <- bind_rows(plot3.male.meta.CVR.b, add.row.hearing)
plot3.male.meta.CVR.b <- plot3.male.meta.CVR.b[order(plot3.male.meta.CVR.b$GroupingTerm), 
    ]

plot3.male.meta.VR.b <- as.data.frame(plot3.male.meta.VR %>% group_by(GroupingTerm) %>% 
    mutate(lnVR = map_dbl(model_lnVR, pluck(2)), lnVR_lower = map_dbl(model_lnVR, 
        pluck(6)), lnVR_upper = map_dbl(model_lnVR, pluck(7)), lnVR_se = map_dbl(model_lnVR, 
        pluck(3))))[, c(1, 4:7)]
plot3.male.meta.VR.b <- plot3.male.meta.VR.b[order(plot3.male.meta.VR.b$GroupingTerm), 
    ]

plot3.male.meta.RR.b <- as.data.frame(plot3.male.meta.RR %>% group_by(GroupingTerm) %>% 
    mutate(lnRR = map_dbl(model_lnRR, pluck(2)), lnRR_lower = map_dbl(model_lnRR, 
        pluck(6)), lnRR_upper = map_dbl(model_lnRR, pluck(7)), lnRR_se = map_dbl(model_lnRR, 
        pluck(3))))[, c(1, 4:7)]
plot3.male.meta.RR.b <- plot3.male.meta.RR.b[order(plot3.male.meta.RR.b$GroupingTerm), 
    ]

overall.male.plot3 <- full_join(plot3.male.meta.CVR.b, plot3.male.meta.VR.b)
overall.male.plot3 <- full_join(overall.male.plot3, plot3.male.meta.RR.b)

overall.male.plot3$GroupingTerm <- factor(overall.male.plot3$GroupingTerm, levels = c("Behaviour", 
    "Morphology", "Metabolism", "Physiology", "Immunology", "Hematology", "Heart", 
    "Hearing", "Eye", "All"))
overall.male.plot3$GroupingTerm <- factor(overall.male.plot3$GroupingTerm, rev(levels(overall.male.plot3$GroupingTerm)))

overall.male.plot3$GroupingTerm <- factor(overall.male.plot3$GroupingTerm, levels = c("Behaviour", 
    "Morphology", "Metabolism", "Physiology", "Immunology", "Hematology", "Heart", 
    "Hearing", "Eye", "All"))
overall.male.plot3$GroupingTerm <- factor(overall.male.plot3$GroupingTerm, rev(levels(overall.male.plot3$GroupingTerm)))

# str(overall.male.plot3)

Restructure MALE data for plotting

overall3.male.sig <- gather(overall.male.plot3, parameter, value, c(lnCVR, lnRR), 
    factor_key = TRUE)

lnCVR.ci <- overall3.male.sig %>% filter(parameter == "lnCVR") %>% mutate(ci.low = lnCVR_lower, 
    ci.high = lnCVR_upper)
# lnVR.ci <- overall3.male.sig %>% filter(parameter == 'lnVR') %>%
# mutate(ci.low = lnVR_lower, ci.high = lnVR_upper)
lnRR.ci <- overall3.male.sig %>% filter(parameter == "lnRR") %>% mutate(ci.low = lnRR_lower, 
    ci.high = lnRR_upper)

overall4.male.sig <- bind_rows(lnCVR.ci, lnRR.ci) %>% select(GroupingTerm, parameter, 
    value, ci.low, ci.high)

overall4.male.sig$label <- "CI not overlapping zero"

Plot Fig 5B all significant results (CI not overlapping zero) for males. This is the right panel in Figure 5B.

Metameta_Fig3_male.sig <- overall4.male.sig %>% ggplot(aes(y = GroupingTerm, 
    x = value)) + geom_errorbarh(aes(xmin = ci.low, xmax = ci.high), height = 0.1, 
    show.legend = FALSE) + geom_point(aes(shape = parameter), fill = "mediumaquamarine", 
    color = "mediumaquamarine", size = 2.2, show.legend = FALSE) + scale_x_continuous(limits = c(0, 
    0.4), breaks = c(0, 0.3), name = "Effect size") + geom_vline(xintercept = 0, 
    color = "black", linetype = "dashed") + facet_grid(cols = vars(parameter), 
    rows = vars(label), labeller = label_wrap_gen(width = 23), scales = "free", 
    space = "free") + theme_bw() + theme(strip.text.y = element_text(angle = 270, 
    size = 10, margin = margin(t = 15, r = 15, b = 15, l = 15)), strip.text.x = element_text(size = 12), 
    strip.background = element_rect(colour = NULL, linetype = "blank", fill = "gray90"), 
    text = element_text(size = 14), panel.spacing = unit(0.5, "lines"), panel.border = element_blank(), 
    axis.line = element_line(), panel.grid.major.x = element_line(linetype = "solid", 
        colour = "gray95"), panel.grid.major.y = element_line(linetype = "solid", 
        color = "gray95"), panel.grid.minor.y = element_blank(), panel.grid.minor.x = element_blank(), 
    legend.title = element_blank(), axis.title.x = element_blank(), axis.title.y = element_blank())

# Metameta_Fig3_male.sig

Female part, significant traits

Female Fig5B sig

Prepare data for traits with CI not overlapping 0 create column with 1= different from zero, 0= zero included in CI

# Female-biased traits

meta.female.plot3.sig <- metacombo %>% mutate(sigCVR = ifelse(lnCVR_upper < 
    0, 1, 0), sigVR = ifelse(lnVR_upper < 0, 1, 0), sigRR = ifelse(lnRR_upper < 
    0, 1, 0))

# Significant subset for lnCVR

metacombo_female.plot3.CVR <- meta.female.plot3.sig %>% filter(sigCVR == 1) %>% 
    group_by(GroupingTerm) %>% nest()

metacombo_female.plot3.CVR.all <- meta.female.plot3.sig %>% filter(sigCVR == 
    1) %>% nest(data = everything())

# Significant subset for lnVR

metacombo_female.plot3.VR <- meta.female.plot3.sig %>% filter(sigVR == 1) %>% 
    group_by(GroupingTerm) %>% nest()

metacombo_female.plot3.VR.all <- meta.female.plot3.sig %>% filter(sigVR == 1) %>% 
    nest(data = everything())

# Significant subset for lnRR

metacombo_female.plot3.RR <- meta.female.plot3.sig %>% filter(sigRR == 1) %>% 
    group_by(GroupingTerm) %>% nest()

# Felix added 7/2/2020: metacombo_female.plot3.RR[4,2][[1]]
# [[1]]$lnRR_upper; #only two data points: -0.12377263 -0.01553462; should
# probably be excluded?!

metacombo_female.plot3.RR.all <- meta.female.plot3.sig %>% filter(sigRR == 1) %>% 
    nest(data = everything())

# **Final fixed effects meta-analyses within grouping terms, with SE of the
# estimate

plot3.female.meta.CVR <- metacombo_female.plot3.CVR %>% mutate(model_lnCVR = map(data, 
    ~metafor::rma.uni(yi = .x$lnCVR, sei = (.x$lnCVR_upper - .x$lnCVR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

plot3.female.meta.VR <- metacombo_female.plot3.VR %>% mutate(model_lnVR = map(data, 
    ~metafor::rma.uni(yi = .x$lnVR, sei = (.x$lnVR_upper - .x$lnVR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

plot3.female.meta.RR <- metacombo_female.plot3.RR %>% mutate(model_lnRR = map(data, 
    ~metafor::rma.uni(yi = .x$lnRR, sei = (.x$lnRR_upper - .x$lnRR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

# Across all grouping terms #

plot3.female.meta.CVR.all <- metacombo_female.plot3.CVR.all %>% mutate(model_lnCVR = map(data, 
    ~metafor::rma.uni(yi = .x$lnCVR, sei = (.x$lnCVR_upper - .x$lnCVR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

plot3.female.meta.CVR.all <- plot3.female.meta.CVR.all %>% mutate(GroupingTerm = "All")

plot3.female.meta.VR.all <- metacombo_female.plot3.VR.all %>% mutate(model_lnVR = map(data, 
    ~metafor::rma.uni(yi = .x$lnVR, sei = (.x$lnVR_upper - .x$lnVR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

plot3.female.meta.VR.all <- plot3.female.meta.VR.all %>% mutate(GroupingTerm = "All")

plot3.female.meta.RR.all <- metacombo_female.plot3.RR.all %>% mutate(model_lnRR = map(data, 
    ~metafor::rma.uni(yi = .x$lnRR, sei = (.x$lnRR_upper - .x$lnRR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

plot3.female.meta.RR.all <- plot3.female.meta.RR.all %>% mutate(GroupingTerm = "All")

# Combine with separate grouping term results

plot3.female.meta.CVR <- bind_rows(plot3.female.meta.CVR, plot3.female.meta.CVR.all)
plot3.female.meta.VR <- bind_rows(plot3.female.meta.VR, plot3.female.meta.VR.all)
plot3.female.meta.RR <- bind_rows(plot3.female.meta.RR, plot3.female.meta.RR.all)

# **Re-structure data for each grouping term; delete un-used variables

plot3.female.meta.CVR.b <- as.data.frame(plot3.female.meta.CVR %>% group_by(GroupingTerm) %>% 
    mutate(lnCVR = map_dbl(model_lnCVR, pluck(2)), lnCVR_lower = map_dbl(model_lnCVR, 
        pluck(6)), lnCVR_upper = map_dbl(model_lnCVR, pluck(7)), lnCVR_se = map_dbl(model_lnCVR, 
        pluck(3))))[, c(1, 4:7)]

add.row.hearing <- as.data.frame(t(c("Hearing", NA, NA, NA, NA))) %>% setNames(names(plot3.female.meta.CVR.b))

plot3.female.meta.CVR.b <- bind_rows(plot3.female.meta.CVR.b, add.row.hearing)
plot3.female.meta.CVR.b <- plot3.female.meta.CVR.b[order(plot3.female.meta.CVR.b$GroupingTerm), 
    ]

plot3.female.meta.VR.b <- as.data.frame(plot3.female.meta.VR %>% group_by(GroupingTerm) %>% 
    mutate(lnVR = map_dbl(model_lnVR, pluck(2)), lnVR_lower = map_dbl(model_lnVR, 
        pluck(6)), lnVR_upper = map_dbl(model_lnVR, pluck(7)), lnVR_se = map_dbl(model_lnVR, 
        pluck(3))))[, c(1, 4:7)]

plot3.female.meta.VR.b <- plot3.female.meta.VR.b[order(plot3.female.meta.VR.b$GroupingTerm), 
    ]

plot3.female.meta.RR.b <- as.data.frame(plot3.female.meta.RR %>% group_by(GroupingTerm) %>% 
    mutate(lnRR = map_dbl(model_lnRR, pluck(2)), lnRR_lower = map_dbl(model_lnRR, 
        pluck(6)), lnRR_upper = map_dbl(model_lnRR, pluck(7)), lnRR_se = map_dbl(model_lnRR, 
        pluck(3))))[, c(1, 4:7)]

plot3.female.meta.RR.b <- plot3.female.meta.RR.b[order(plot3.female.meta.RR.b$GroupingTerm), 
    ]

overall.female.plot3 <- full_join(plot3.female.meta.CVR.b, plot3.female.meta.VR.b)
overall.female.plot3 <- full_join(overall.female.plot3, plot3.female.meta.RR.b)

overall.female.plot3$GroupingTerm <- factor(overall.female.plot3$GroupingTerm, 
    levels = c("Behaviour", "Morphology", "Metabolism", "Physiology", "Immunology", 
        "Hematology", "Heart", "Hearing", "Eye", "All"))
overall.female.plot3$GroupingTerm <- factor(overall.female.plot3$GroupingTerm, 
    rev(levels(overall.female.plot3$GroupingTerm)))

Re-structure data for plotting

overall3.female.sig <- gather(overall.female.plot3, parameter, value, c(lnCVR, 
    lnRR), factor_key = TRUE)

lnCVR.ci <- overall3.female.sig %>% filter(parameter == "lnCVR") %>% mutate(ci.low = lnCVR_lower, 
    ci.high = lnCVR_upper)
# lnVR.ci <- overall3.female.sig %>% filter(parameter == 'lnVR') %>%
# mutate(ci.low = lnVR_lower, ci.high = lnVR_upper)
lnRR.ci <- overall3.female.sig %>% filter(parameter == "lnRR") %>% mutate(ci.low = lnRR_lower, 
    ci.high = lnRR_upper)

overall4.female.sig <- bind_rows(lnCVR.ci, lnRR.ci) %>% select(GroupingTerm, 
    parameter, value, ci.low, ci.high)  # lnVR.ci,

overall4.female.sig$label <- "CI not overlapping zero"

Plotting Fig5B all significant results (CI not overlapping zero, female )

Metameta_Fig3_female.sig  <- overall4.female.sig %>%
  ggplot(aes(y = GroupingTerm, x = value)) +
  geom_errorbarh(aes(
    xmin = ci.low,
    xmax = ci.high
  ),
  height = 0.1, show.legend = FALSE
  ) +
  geom_point(aes(shape = parameter),
    fill = "salmon1", color = "salmon1", size = 2.2,
    show.legend = FALSE
  ) +
  scale_x_continuous(
    limits = c(-0.4, 0),
    breaks = c(-0.3, 0),
    name = "Effect size"
  ) +
  geom_vline(
    xintercept = 0,
    color = "black",
    linetype = "dashed"
  ) +
  facet_grid(
    cols = vars(parameter), # rows = vars(label),
    # labeller = label_wrap_gen(width = 23),
    scales = "free",
    space = "free"
  ) +
  theme_bw() +
  theme(
    strip.text.y = element_text(angle = 270, size = 10, margin = margin(t = 15, r = 15, b = 15, l = 15)),
    strip.text.x = element_text(size = 12),
    strip.background = element_rect(colour = NULL, linetype = "blank", fill = "gray90"),
    text = element_text(size = 14),
    panel.spacing = unit(0.5, "lines"),
    panel.border = element_blank(),
    axis.line = element_line(),
    panel.grid.major.x = element_line(linetype = "solid", colour = "gray95"),
    panel.grid.major.y = element_line(linetype = "solid", color = "gray95"),
    panel.grid.minor.y = element_blank(),
    panel.grid.minor.x = element_blank(),
    legend.title = element_blank(),
    axis.title.x = element_blank(),
    axis.title.y = element_blank()
  )

# Metameta_Fig3_female.sig #(Figure 5B left panel)

JOIN!!! CODE MISSING??

malebias_Fig2_sigtraits Metameta_Fig3_female.sig #(Figure 5B left panel) Metameta_Fig3_male.sig

Fig5B <- ggarrange(Metameta_Fig3_female.sig, Metameta_Fig3_male.sig, ncol = 2, 
    nrow = 1, widths = c(1, 1.2), heights = c(1, 1))

Fig5 <- ggarrange(malebias_Fig2_sigtraits, Fig5B, ncol = 1, nrow = 2, widths = c(1, 
    1.1), heights = c(1.1, 1), labels = c("A", "B"))
Fig5

Supplemental Plots

Figure S1

Including lnVR

Count data, including lnVR (Fig S1 panel A)

# *Prepare data for all traits

meta.plot2.all <- meta_clean %>% select(lnCVR, lnVR, lnRR, GroupingTerm) %>% 
    arrange(GroupingTerm)

meta.plot2.all.bS1 <- gather(meta.plot2.all, trait, value, c(lnCVR, lnVR, lnRR))

meta.plot2.all.bS1$trait <- factor(meta.plot2.all.bS1$trait, levels = c("lnCVR", 
    "lnVR", "lnRR"))

meta.plot2.all.cS1 <- meta.plot2.all.bS1 %>% group_by_at(vars(trait, GroupingTerm)) %>% 
    summarise(malebias = sum(value > 0), femalebias = sum(value <= 0), total = malebias + 
        femalebias, malepercent = malebias * 100/total, femalepercent = femalebias * 
        100/total)

meta.plot2.all.cS1$label <- "All traits"

# Re-structure to create stacked bar plots

meta.plot2.all.dS1 <- as.data.frame(meta.plot2.all.cS1)
meta.plot2.all.eS1 <- gather(meta.plot2.all.dS1, key = sex, value = percent, 
    malepercent:femalepercent, factor_key = TRUE)

# Create new sample size variable

meta.plot2.all.eS1$samplesize <- with(meta.plot2.all.eS1, ifelse(sex == "malepercent", 
    malebias, femalebias))

# Add summary row ('All') and re-arrange rows into correct order for
# plotting (warnings about coercing 'id' into character vector are ok)

meta.plot2.all.fS1 <- meta.plot2.all.eS1 %>% group_by(trait, sex) %>% summarise(GroupingTerm = "All", 
    malebias = sum(malebias), femalebias = sum(femalebias), total = malebias + 
        femalebias, label = "All traits", samplesize = sum(samplesize)) %>% 
    mutate(percent = ifelse(sex == "femalepercent", femalebias * 100/(malebias + 
        femalebias), malebias * 100/(malebias + femalebias))) %>% bind_rows(meta.plot2.all.eS1, 
    .) %>% mutate(rownumber = row_number()) %>% .[c(55, 1:9, 57, 10:18, 59, 
    19:27, 56, 28:36, 58, 37:45, 60, 46:54), ]

meta.plot2.all.fS1$GroupingTerm <- factor(meta.plot2.all.fS1$GroupingTerm, levels = c("Behaviour", 
    "Morphology", "Metabolism", "Physiology", "Immunology", "Hematology", "Heart", 
    "Hearing", "Eye", "All"))
meta.plot2.all.fS1$GroupingTerm <- factor(meta.plot2.all.fS1$GroupingTerm, rev(levels(meta.plot2.all.fS1$GroupingTerm)))

malebias_FigS1_alltraits <- ggplot(meta.plot2.all.fS1) + aes(x = GroupingTerm, 
    y = percent, fill = sex) + geom_col() + geom_hline(yintercept = 50, linetype = "dashed", 
    color = "gray40") + geom_text(data = subset(meta.plot2.all.fS1, samplesize != 
    0), aes(label = samplesize), position = position_stack(vjust = 0.5), color = "white", 
    size = 3.5) + facet_grid(cols = vars(trait), rows = vars(label), labeller = label_wrap_gen(width = 18), 
    scales = "free", space = "free") + scale_fill_brewer(palette = "Set2") + 
    theme_bw(base_size = 18) + theme(strip.text.y = element_text(angle = 270, 
    size = 10, margin = margin(t = 15, r = 15, b = 15, l = 15)), strip.text.x = element_text(size = 12), 
    strip.background = element_rect(colour = NULL, linetype = "blank", fill = "gray90"), 
    text = element_text(size = 14), panel.spacing = unit(0.5, "lines"), panel.border = element_blank(), 
    axis.line = element_line(), panel.grid.major.x = element_line(linetype = "solid", 
        colour = "gray95"), panel.grid.major.y = element_line(linetype = "solid", 
        color = "gray95"), panel.grid.minor.y = element_blank(), panel.grid.minor.x = element_blank(), 
    legend.position = "none", axis.title.x = element_blank(), axis.title.y = element_blank()) + 
    coord_flip()

# malebias_FigS1_alltraits #(panel A in Figure S1)

Overall results of second order meta analysis, INCLUDING VR

Re-structure data for plotting

Restructure MALE data for plotting

overall3.male.sigS <- gather(overall.male.plot3, parameter, value, c(lnCVR, 
    lnVR, lnRR), factor_key = TRUE)

lnCVR.ci <- overall3.male.sigS %>% filter(parameter == "lnCVR") %>% mutate(ci.low = lnCVR_lower, 
    ci.high = lnCVR_upper)
lnVR.ci <- overall3.male.sigS %>% filter(parameter == "lnVR") %>% mutate(ci.low = lnVR_lower, 
    ci.high = lnVR_upper)
lnRR.ci <- overall3.male.sigS %>% filter(parameter == "lnRR") %>% mutate(ci.low = lnRR_lower, 
    ci.high = lnRR_upper)

overall4.male.sigS <- bind_rows(lnCVR.ci, lnVR.ci, lnRR.ci) %>% select(GroupingTerm, 
    parameter, value, ci.low, ci.high)

overall4.male.sigS$label <- "CI not overlapping zero"

# Data are re-structured, and grouping terms are being re-ordered

overall3S <- gather(overall2, parameter, value, c(lnCVR, lnVR, lnRR), factor_key = TRUE)

lnCVR.ci <- overall3S %>% filter(parameter == "lnCVR") %>% mutate(ci.low = lnCVR_lower, 
    ci.high = lnCVR_upper)
lnVR.ci <- overall3S %>% filter(parameter == "lnVR") %>% mutate(ci.low = lnVR_lower, 
    ci.high = lnVR_upper)
lnRR.ci <- overall3S %>% filter(parameter == "lnRR") %>% mutate(ci.low = lnRR_lower, 
    ci.high = lnRR_upper)

overall4S <- bind_rows(lnCVR.ci, lnVR.ci, lnRR.ci) %>% select(GroupingTerm, 
    parameter, value, ci.low, ci.high)

# Re-order grouping terms

overall4S$GroupingTerm <- factor(overall4S$GroupingTerm, levels = c("Behaviour", 
    "Morphology", "Metabolism", "Physiology", "Immunology", "Hematology", "Heart", 
    "Hearing", "Eye", "All"))
overall4S$GroupingTerm <- factor(overall4S$GroupingTerm, rev(levels(overall4S$GroupingTerm)))
overall4S$label <- "All traits"

Preparation for plot, including lnVR

Preparation: Sub-Plot for Figure S1: all traits (S1 B)

Metameta_FigS1_alltraits <- overall4S %>% 
ggplot(aes(y = GroupingTerm, x = value)) + geom_errorbarh(aes(xmin = ci.low, 
    xmax = ci.high), height = 0.1, show.legend = FALSE) + geom_point(aes(shape = parameter), 
    fill = "black", color = "black", size = 2.2, show.legend = FALSE) + scale_x_continuous(limits = c(-0.24, 
    0.25), breaks = c(-0.2, -0.1, 0, 0.1, 0.2), name = "Effect size") + geom_vline(xintercept = 0, 
    color = "black", linetype = "dashed") + facet_grid(cols = vars(parameter), 
    rows = vars(label), labeller = label_wrap_gen(width = 23), scales = "free", 
    space = "free") + theme_bw() + theme(strip.text.y = element_text(angle = 270, 
    size = 10, margin = margin(t = 15, r = 15, b = 15, l = 15)), strip.text.x = element_text(size = 12), 
    strip.background = element_rect(colour = NULL, linetype = "blank", fill = "gray90"), 
    text = element_text(size = 14), panel.spacing = unit(0.5, "lines"), panel.border = element_blank(), 
    axis.line = element_line(), panel.grid.major.x = element_line(linetype = "solid", 
        colour = "gray95"), panel.grid.major.y = element_line(linetype = "solid", 
        color = "gray95"), panel.grid.minor.y = element_blank(), panel.grid.minor.x = element_blank(), 
    legend.title = element_blank(), axis.title.x = element_text(hjust = 0.5, 
        size = 14), axis.title.y = element_blank())

# Metameta_FigS1_alltraits

Heterogeneity

The analysis for heterogeneity follows the workflow of the above steps for the different meta-analyses. However, in the initial meta-analysis we extract sigma^2 and errors for mouse strains and centers (Institutions).

# Create dataframe to store results
results.allhetero.grouping <- as.data.frame(cbind(c(1:n), matrix(rep(0, n * 
    30), ncol = 30)))
names(results.allhetero.grouping) <- c("id", "sigma2_strain.CVR", "sigma2_center.CVR", 
    "sigma2_error.CVR", "s.nlevels.strain.CVR", "s.nlevels.center.CVR", "s.nlevels.error.CVR", 
    "sigma2_strain.VR", "sigma2_center.VR", "sigma2_error.VR", "s.nlevels.strain.VR", 
    "s.nlevels.center.VR", "s.nlevels.error.VR", "sigma2_strain.RR", "sigma2_center.RR", 
    "sigma2_error.RR", "s.nlevels.strain.RR", "s.nlevels.center.RR", "s.nlevels.error.RR", 
    "lnCVR", "lnCVR_lower", "lnCVR_upper", "lnCVR_se", "lnVR", "lnVR_lower", 
    "lnVR_upper", "lnVR_se", "lnRR", "lnRR_lower", "lnRR_upper", "lnRR_se")

LOOP Parameters to extract from metafor (sigma2’s, s.nlevels)

for (t in 1:n) {
    tryCatch({
        data_par_age <- data_subset_parameterid_individual_by_age(data, t, age_min = 0, 
            age_center = 100)
        
        population_stats <- calculate_population_stats(data_par_age)
        
        results <- create_meta_analysis_effect_sizes(population_stats)
        
        # lnCVR, logaritm of the ratio of male and female coefficients of variance
        
        cvr. <- metafor::rma.mv(yi = effect_size_CVR, V = sample_variance_CVR, 
            random = list(~1 | strain_name, ~1 | production_center, ~1 | err), 
            control = list(optimizer = "optim", optmethod = "Nelder-Mead", maxit = 1000), 
            data = results)
        results.allhetero.grouping[t, 2] <- cvr.$sigma2[1]
        results.allhetero.grouping[t, 3] <- cvr.$sigma2[2]
        results.allhetero.grouping[t, 4] <- cvr.$sigma2[3]
        results.allhetero.grouping[t, 5] <- cvr.$s.nlevels[1]
        results.allhetero.grouping[t, 6] <- cvr.$s.nlevels[2]
        results.allhetero.grouping[t, 7] <- cvr.$s.nlevels[3]
        results.allhetero.grouping[t, 20] <- cvr.$b
        results.allhetero.grouping[t, 21] <- cvr.$ci.lb
        results.allhetero.grouping[t, 22] <- cvr.$ci.ub
        results.allhetero.grouping[t, 23] <- cvr.$se
        
        # lnVR, male to female variability ratio (logarithm of male and female
        # standard deviations)
        
        vr. <- metafor::rma.mv(yi = effect_size_VR, V = sample_variance_VR, 
            random = list(~1 | strain_name, ~1 | production_center, ~1 | err), 
            control = list(optimizer = "optim", optmethod = "Nelder-Mead", maxit = 1000), 
            data = results)
        results.allhetero.grouping[t, 8] <- vr.$sigma2[1]
        results.allhetero.grouping[t, 9] <- vr.$sigma2[2]
        results.allhetero.grouping[t, 10] <- vr.$sigma2[3]
        results.allhetero.grouping[t, 11] <- vr.$s.nlevels[1]
        results.allhetero.grouping[t, 12] <- vr.$s.nlevels[2]
        results.allhetero.grouping[t, 13] <- vr.$s.nlevels[3]
        results.allhetero.grouping[t, 24] <- vr.$b
        results.allhetero.grouping[t, 25] <- vr.$ci.lb
        results.allhetero.grouping[t, 26] <- vr.$ci.ub
        results.allhetero.grouping[t, 27] <- vr.$se
        
        # lnRR, response ratio (logarithm of male and female means)
        
        rr. <- metafor::rma.mv(yi = effect_size_RR, V = sample_variance_RR, 
            random = list(~1 | strain_name, ~1 | production_center, ~1 | err), 
            control = list(optimizer = "optim", optmethod = "Nelder-Mead", maxit = 1000), 
            data = results)
        results.allhetero.grouping[t, 14] <- rr.$sigma2[1]
        results.allhetero.grouping[t, 15] <- rr.$sigma2[2]
        results.allhetero.grouping[t, 16] <- rr.$sigma2[3]
        results.allhetero.grouping[t, 17] <- rr.$s.nlevels[1]
        results.allhetero.grouping[t, 18] <- rr.$s.nlevels[2]
        results.allhetero.grouping[t, 19] <- rr.$s.nlevels[3]
        results.allhetero.grouping[t, 28] <- rr.$b
        results.allhetero.grouping[t, 29] <- rr.$ci.lb
        results.allhetero.grouping[t, 30] <- rr.$ci.ub
        results.allhetero.grouping[t, 31] <- rr.$se
    }, error = function(e) {
        cat("ERROR :", conditionMessage(e), "\n")
    })
}
## ERROR : Optimizer (optim) did not achieve convergence (convergence = 10). 
## ERROR : Optimizer (optim) did not achieve convergence (convergence = 10). 
## ERROR : NA/NaN/Inf in 'y' 
## ERROR : NA/NaN/Inf in 'y' 
## ERROR : NA/NaN/Inf in 'y' 
## ERROR : NA/NaN/Inf in 'y' 
## ERROR : NA/NaN/Inf in 'y' 
## ERROR : NA/NaN/Inf in 'y' 
## ERROR : NA/NaN/Inf in 'y' 
## ERROR : NA/NaN/Inf in 'y'

Exclude traits without variation between mouse strains; merge datasets #Felix added 6/2/2020

results.allhetero.grouping2 <- results.allhetero.grouping[results.allhetero.grouping$s.nlevels.strain.VR != 
    0, ]
# nrow(results.allhetero.grouping) #223 Felix 7/2/2020 added: not sure. Run
# again and it was 232?!

Merge data sets containing metafor results with procedure etc. names

# procedures <- read.csv(here('export', 'procedures.csv'))

results.allhetero.grouping2$parameter_group <- data$parameter_group[match(results.allhetero.grouping2$id, 
    data$id)]
results.allhetero.grouping2$procedure <- data$procedure_name[match(results.allhetero.grouping2$id, 
    data$id)]

results.allhetero.grouping2$GroupingTerm <- procedures$GroupingTerm[match(results.allhetero.grouping2$procedure, 
    procedures$procedure)]
results.allhetero.grouping2$parameter_name <- data$parameter_name[match(results.allhetero.grouping2$id, 
    data$id)]

Correlated parameters

metahetero1 <- results.allhetero.grouping2
# length(unique(metahetero1$procedure)) #19
# length(unique(metahetero1$GroupingTerm)) #9 
# length(unique(metahetero1$parameter_group)) #152
# length(unique(metahetero1$parameter_name)) #223

# Count of number of parameter names (correlated sub-traits) in each parameter group (par_group_size)

metahetero1b <-
  metahetero1 %>%
  group_by(parameter_group) %>%
  mutate(par_group_size = n_distinct(parameter_name))

metahetero1$par_group_size <- metahetero1b$par_group_size[match(metahetero1$parameter_group, metahetero1b$parameter_group)]

# Create subsets with > 1 count (par_group_size > 1)

metahetero1_sub <- subset(metahetero1, par_group_size > 1) # 92 observations
# str(metahetero1_sub)
# metahetero1_sub$sampleSize <- as.numeric(metahetero1_sub$sampleSize) #from previous analysis? don't think is used: : delete in final version

# Nest data

n_count. <- metahetero1_sub %>%
  group_by(parameter_group) %>%
  # mutate(raw_N = sum(sampleSize)) %>%  #Felix added: don't think is necessary: delete in final version
  nest()

# meta-analysis preparation

model_count. <- n_count. %>%
  mutate(
    model_lnRR = map(data, ~ robu(.x$lnRR ~ 1,
      data = .x, studynum = .x$id, modelweights = c("CORR"), rho = 0.8,
      small = TRUE, var.eff.size = (.x$lnRR_se)^2
    )),
    model_lnVR = map(data, ~ robu(.x$lnVR ~ 1,
      data = .x, studynum = .x$id, modelweights = c("CORR"), rho = 0.8,
      small = TRUE, var.eff.size = (.x$lnVR_se)^2
    )),
    model_lnCVR = map(data, ~ robu(.x$lnCVR ~ 1,
      data = .x, studynum = .x$id, modelweights = c("CORR"), rho = 0.8,
      small = TRUE, var.eff.size = (.x$lnCVR_se)^2
    ))
  )


# Robumeta object details:
# str(model_count.$model_lnCVR[[1]])

## *Perform meta-analyses on correlated sub-traits, using robumeta
 # Susi / FELIX: what's this below?
# Shinichi: We think we want to use these for further analyses:
# residual variance: as.numeric(robu_fit$mod_info$term1)     (same as 'mod_info$tau.sq')
# sample size: robu_fit$N

## **Extract and save parameter estimates

# Felix: doesn't work , error message:
#!!!!!!!!!!! ERROR!!!!!!!!!!!!!!!!!!!!
#Error: Column `parameter_group` can't be modified because it's a grouping variable

count_fun. <- function(mod_sub) {
  return(c(as.numeric(mod_sub$mod_info$term1), mod_sub$N))
}

robusub_RR. <- model_count. %>%
  transmute(estimatelnRR = map(model_lnRR, count_fun.)) %>%    #Felix 4/2/2020: deleted: 'parameter_group' (in brackets, after 'transmute')
  mutate(r = map(estimatelnRR, ~ data.frame(t(.)))) %>%
  unnest(r) %>%
  select(-estimatelnRR) %>%
  purrr::set_names(c("parameter_group", "var.RR", "N.RR"))

robusub_CVR. <- model_count. %>%
  transmute(estimatelnCVR = map(model_lnCVR, count_fun.)) %>%
  mutate(r = map(estimatelnCVR, ~ data.frame(t(.)))) %>%
  unnest(r) %>%
  select(-estimatelnCVR) %>%
  purrr::set_names(c("parameter_group", "var.CVR", "N.CVR"))

robusub_VR. <- model_count. %>%
  transmute(estimatelnVR = map(model_lnVR, count_fun.)) %>%
  mutate(r = map(estimatelnVR, ~ data.frame(t(.)))) %>%
  unnest(r) %>%
  select(-estimatelnVR) %>%
  purrr::set_names(c("parameter_group", "var.VR", "N.VR"))

robu_all. <- full_join(robusub_CVR., robusub_VR.) %>% full_join(., robusub_RR.)

Merge the two data sets (the new [robu_all.] and the initial [uncorrelated sub-traits with count = 1])

In this step, we
1) merge the N from robumeta and the N from metafor (s.nlevels.error) together into the same columns (N.RR, N.VR, N.CVR) 2) calculate the total variance for metafor models as the sum of random effect variances and the residual error, then add in the same columns together with the residual variances from robumeta

metahetero_all <- metahetero1 %>%
  filter(par_group_size == 1) %>%
  as_tibble()
metahetero_all$N.RR <- metahetero_all$s.nlevels.error.RR
metahetero_all$N.CVR <- metahetero_all$s.nlevels.error.CVR
metahetero_all$N.VR <- metahetero_all$s.nlevels.error.VR
metahetero_all$var.RR <- log(sqrt(metahetero_all$sigma2_strain.RR + metahetero_all$sigma2_center.RR + metahetero_all$sigma2_error.RR))
metahetero_all$var.VR <- log(sqrt(metahetero_all$sigma2_strain.VR + metahetero_all$sigma2_center.VR + metahetero_all$sigma2_error.VR))
metahetero_all$var.CVR <- log(sqrt(metahetero_all$sigma2_strain.CVR + metahetero_all$sigma2_center.CVR + metahetero_all$sigma2_error.CVR))
# str(metahetero_all)
# str(robu_all.)

metahetero_all <- metahetero_all %>% mutate(
  var.RR = if_else(var.RR == -Inf, -7, var.RR),   #Felix commented 6/2/2020: can't remmeber, why -7, -6, -5 in this section!
  var.VR = if_else(var.VR == -Inf, -5, var.VR),
  var.CVR = if_else(var.CVR == -Inf, -6, var.CVR)
)

# **Combine data
## Step1
combinedmetahetero <- bind_rows(robu_all., metahetero_all)
# glimpse(combinedmetahetero)

# Steps 2&3

metacombohetero <- combinedmetahetero
metacombohetero$counts <- metahetero1$par_group_size[match(metacombohetero$parameter_group, metahetero1$parameter_group)]
metacombohetero$procedure2 <- metahetero1$procedure[match(metacombohetero$parameter_group, metahetero1$parameter_group)]
metacombohetero$GroupingTerm2 <- metahetero1$GroupingTerm[match(metacombohetero$parameter_group, metahetero1$parameter_group)]

# **Clean-up and rename

metacombohetero <- metacombohetero %>% select(parameter_group, var.CVR, N.CVR, var.VR, N.VR, var.RR, N.RR, counts, procedure = procedure2, GroupingTerm = GroupingTerm2)  #Felix changed 6/2/2020: was: c(1:7, 43:45, and 2 renaming lines)

Meta-analysis of heterogeneity

## Perform meta-meta-analysis (3 for each of the 9 grouping terms: var.CVR,
## var.VR, var.RR)

metacombohetero_final <- metacombohetero %>% group_by(GroupingTerm) %>% nest()

# Final fixed effects meta-analyses within grouping terms, with SE of the
# estimate

heterog1 <- metacombohetero_final %>% 
mutate(model_heteroCVR = map(data, ~metafor::rma.uni(yi = .x$var.CVR, sei = sqrt(1/2 * 
    (.x$N.CVR - 1)), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
    maxit = 10000, stepadj = 0.5), verbose = F)), model_heteroVR = map(data, 
    ~metafor::rma.uni(yi = .x$var.VR, sei = sqrt(1/2 * (.x$N.VR - 1)), control = list(optimizer = "optim", 
        optmethod = "Nelder-Mead", maxit = 10000, stepadj = 0.5), verbose = F)), 
    model_heteroRR = map(data, ~metafor::rma.uni(yi = .x$var.RR, sei = sqrt(1/2 * 
        (.x$N.RR - 1)), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 10000, stepadj = 0.5), verbose = F)))

# Across all grouping terms

metacombohetero_all_final <- metacombohetero %>% nest(data = everything())

# Final fixed effects meta-analyses ACROSS grouping terms, with SE of the
# estimate

heterog1_all <- metacombohetero_all_final %>% 
mutate(model_heteroCVR = map(data, ~metafor::rma.uni(yi = .x$var.CVR, sei = sqrt(1/2 * 
    (.x$N.CVR - 1)), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
    maxit = 10000, stepadj = 0.5), verbose = F)), model_heteroVR = map(data, 
    ~metafor::rma.uni(yi = .x$var.VR, sei = sqrt(1/2 * (.x$N.VR - 1)), control = list(optimizer = "optim", 
        optmethod = "Nelder-Mead", maxit = 10000, stepadj = 0.5), verbose = F)), 
    model_heteroRR = map(data, ~metafor::rma.uni(yi = .x$var.RR, sei = sqrt(1/2 * 
        (.x$N.RR - 1)), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 10000, stepadj = 0.5), verbose = F)))


# Re-structure data for each grouping term; extract heterogenenity/variance
# terms; delete un-used variables

Behaviour. <- heterog1 %>% filter(., GroupingTerm == "Behaviour") %>% select(., 
    -data) %>% mutate(heteroCVR = .[[2]][[1]]$b, heteroCVR_lower = .[[2]][[1]]$ci.lb, 
    heteroCVR_upper = .[[2]][[1]]$ci.ub, heteroCVR_se = .[[2]][[1]]$se, heteroVR = .[[3]][[1]]$b, 
    heteroVR_lower = .[[3]][[1]]$ci.lb, heteroVR_upper = .[[3]][[1]]$ci.ub, 
    heteroVR_se = .[[3]][[1]]$se, heteroRR = .[[4]][[1]]$b, heteroRR_lower = .[[4]][[1]]$ci.lb, 
    heteroRR_upper = .[[4]][[1]]$ci.ub, heteroRR_se = .[[4]][[1]]$se) %>% select(., 
    GroupingTerm, heteroCVR:heteroRR_se)

Immunology. <- heterog1 %>% filter(., GroupingTerm == "Immunology") %>% select(., 
    -data) %>% mutate(heteroCVR = .[[2]][[1]]$b, heteroCVR_lower = .[[2]][[1]]$ci.lb, 
    heteroCVR_upper = .[[2]][[1]]$ci.ub, heteroCVR_se = .[[2]][[1]]$se, heteroVR = .[[3]][[1]]$b, 
    heteroVR_lower = .[[3]][[1]]$ci.lb, heteroVR_upper = .[[3]][[1]]$ci.ub, 
    heteroVR_se = .[[3]][[1]]$se, heteroRR = .[[4]][[1]]$b, heteroRR_lower = .[[4]][[1]]$ci.lb, 
    heteroRR_upper = .[[4]][[1]]$ci.ub, heteroRR_se = .[[4]][[1]]$se) %>% select(., 
    GroupingTerm, heteroCVR:heteroRR_se)

Hematology. <- heterog1 %>% filter(., GroupingTerm == "Hematology") %>% select(., 
    -data) %>% mutate(heteroCVR = .[[2]][[1]]$b, heteroCVR_lower = .[[2]][[1]]$ci.lb, 
    heteroCVR_upper = .[[2]][[1]]$ci.ub, heteroCVR_se = .[[2]][[1]]$se, heteroVR = .[[3]][[1]]$b, 
    heteroVR_lower = .[[3]][[1]]$ci.lb, heteroVR_upper = .[[3]][[1]]$ci.ub, 
    heteroVR_se = .[[3]][[1]]$se, heteroRR = .[[4]][[1]]$b, heteroRR_lower = .[[4]][[1]]$ci.lb, 
    heteroRR_upper = .[[4]][[1]]$ci.ub, heteroRR_se = .[[4]][[1]]$se) %>% select(., 
    GroupingTerm, heteroCVR:heteroRR_se)


Hearing. <- heterog1 %>% filter(., GroupingTerm == "Hearing") %>% select(., 
    -data) %>% mutate(heteroCVR = .[[2]][[1]]$b, heteroCVR_lower = .[[2]][[1]]$ci.lb, 
    heteroCVR_upper = .[[2]][[1]]$ci.ub, heteroCVR_se = .[[2]][[1]]$se, heteroVR = .[[3]][[1]]$b, 
    heteroVR_lower = .[[3]][[1]]$ci.lb, heteroVR_upper = .[[3]][[1]]$ci.ub, 
    heteroVR_se = .[[3]][[1]]$se, heteroRR = .[[4]][[1]]$b, heteroRR_lower = .[[4]][[1]]$ci.lb, 
    heteroRR_upper = .[[4]][[1]]$ci.ub, heteroRR_se = .[[4]][[1]]$se) %>% select(., 
    GroupingTerm, heteroCVR:heteroRR_se)

Physiology. <- heterog1 %>% filter(., GroupingTerm == "Physiology") %>% select(., 
    -data) %>% mutate(heteroCVR = .[[2]][[1]]$b, heteroCVR_lower = .[[2]][[1]]$ci.lb, 
    heteroCVR_upper = .[[2]][[1]]$ci.ub, heteroCVR_se = .[[2]][[1]]$se, heteroVR = .[[3]][[1]]$b, 
    heteroVR_lower = .[[3]][[1]]$ci.lb, heteroVR_upper = .[[3]][[1]]$ci.ub, 
    heteroVR_se = .[[3]][[1]]$se, heteroRR = .[[4]][[1]]$b, heteroRR_lower = .[[4]][[1]]$ci.lb, 
    heteroRR_upper = .[[4]][[1]]$ci.ub, heteroRR_se = .[[4]][[1]]$se) %>% select(., 
    GroupingTerm, heteroCVR:heteroRR_se)

Metabolism. <- heterog1 %>% filter(., GroupingTerm == "Metabolism") %>% select(., 
    -data) %>% mutate(heteroCVR = .[[2]][[1]]$b, heteroCVR_lower = .[[2]][[1]]$ci.lb, 
    heteroCVR_upper = .[[2]][[1]]$ci.ub, heteroCVR_se = .[[2]][[1]]$se, heteroVR = .[[3]][[1]]$b, 
    heteroVR_lower = .[[3]][[1]]$ci.lb, heteroVR_upper = .[[3]][[1]]$ci.ub, 
    heteroVR_se = .[[3]][[1]]$se, heteroRR = .[[4]][[1]]$b, heteroRR_lower = .[[4]][[1]]$ci.lb, 
    heteroRR_upper = .[[4]][[1]]$ci.ub, heteroRR_se = .[[4]][[1]]$se) %>% select(., 
    GroupingTerm, heteroCVR:heteroRR_se)

Morphology. <- heterog1 %>% filter(., GroupingTerm == "Morphology") %>% select(., 
    -data) %>% mutate(heteroCVR = .[[2]][[1]]$b, heteroCVR_lower = .[[2]][[1]]$ci.lb, 
    heteroCVR_upper = .[[2]][[1]]$ci.ub, heteroCVR_se = .[[2]][[1]]$se, heteroVR = .[[3]][[1]]$b, 
    heteroVR_lower = .[[3]][[1]]$ci.lb, heteroVR_upper = .[[3]][[1]]$ci.ub, 
    heteroVR_se = .[[3]][[1]]$se, heteroRR = .[[4]][[1]]$b, heteroRR_lower = .[[4]][[1]]$ci.lb, 
    heteroRR_upper = .[[4]][[1]]$ci.ub, heteroRR_se = .[[4]][[1]]$se) %>% select(., 
    GroupingTerm, heteroCVR:heteroRR_se)

Heart. <- heterog1 %>% filter(., GroupingTerm == "Heart") %>% select(., -data) %>% 
    mutate(heteroCVR = .[[2]][[1]]$b, heteroCVR_lower = .[[2]][[1]]$ci.lb, heteroCVR_upper = .[[2]][[1]]$ci.ub, 
        heteroCVR_se = .[[2]][[1]]$se, heteroVR = .[[3]][[1]]$b, heteroVR_lower = .[[3]][[1]]$ci.lb, 
        heteroVR_upper = .[[3]][[1]]$ci.ub, heteroVR_se = .[[3]][[1]]$se, heteroRR = .[[4]][[1]]$b, 
        heteroRR_lower = .[[4]][[1]]$ci.lb, heteroRR_upper = .[[4]][[1]]$ci.ub, 
        heteroRR_se = .[[4]][[1]]$se) %>% select(., GroupingTerm, heteroCVR:heteroRR_se)

Eye. <- heterog1 %>% filter(., GroupingTerm == "Eye") %>% select(., -data) %>% 
    mutate(heteroCVR = .[[2]][[1]]$b, heteroCVR_lower = .[[2]][[1]]$ci.lb, heteroCVR_upper = .[[2]][[1]]$ci.ub, 
        heteroCVR_se = .[[2]][[1]]$se, heteroVR = .[[3]][[1]]$b, heteroVR_lower = .[[3]][[1]]$ci.lb, 
        heteroVR_upper = .[[3]][[1]]$ci.ub, heteroVR_se = .[[3]][[1]]$se, heteroRR = .[[4]][[1]]$b, 
        heteroRR_lower = .[[4]][[1]]$ci.lb, heteroRR_upper = .[[4]][[1]]$ci.ub, 
        heteroRR_se = .[[4]][[1]]$se) %>% select(., GroupingTerm, heteroCVR:heteroRR_se)

# Reorder to be able to keep cell referencing
heterog1_all <- heterog1_all %>% mutate(GroupingTerm = "All") %>% select(GroupingTerm, 
    everything())

All. <- heterog1_all %>% select(., -data) %>% mutate(heteroCVR = .[[2]][[1]]$b, 
    heteroCVR_lower = .[[2]][[1]]$ci.lb, heteroCVR_upper = .[[2]][[1]]$ci.ub, 
    heteroCVR_se = .[[2]][[1]]$se, heteroVR = .[[3]][[1]]$b, heteroVR_lower = .[[3]][[1]]$ci.lb, 
    heteroVR_upper = .[[3]][[1]]$ci.ub, heteroVR_se = .[[3]][[1]]$se, heteroRR = .[[4]][[1]]$b, 
    heteroRR_lower = .[[4]][[1]]$ci.lb, heteroRR_upper = .[[4]][[1]]$ci.ub, 
    heteroRR_se = .[[4]][[1]]$se) %>% select(., GroupingTerm, heteroCVR:heteroRR_se)

heterog2 <- bind_rows(Behaviour., Morphology., Metabolism., Physiology., Immunology., 
    Hematology., Heart., Hearing., Eye., All.)
# str(heterog2)

Heterogeneity PLOT

Restructure data for plotting

heterog3 <- gather(heterog2, parameter, value, c(heteroCVR, heteroVR, heteroRR), 
    factor_key = TRUE)

heteroCVR.ci <- heterog3 %>% filter(parameter == "heteroCVR") %>% mutate(ci.low = heteroCVR_lower, 
    ci.high = heteroCVR_upper)
heteroVR.ci <- heterog3 %>% filter(parameter == "heteroVR") %>% mutate(ci.low = heteroVR_lower, 
    ci.high = heteroVR_upper)
heteroRR.ci <- heterog3 %>% filter(parameter == "heteroRR") %>% mutate(ci.low = heteroRR_lower, 
    ci.high = heteroRR_upper)

heterog4 <- bind_rows(heteroCVR.ci, heteroVR.ci, heteroRR.ci) %>% select(GroupingTerm, 
    parameter, value, ci.low, ci.high)

# **Re-order grouping terms

heterog4$GroupingTerm <- factor(heterog4$GroupingTerm, levels = c("Behaviour", 
    "Morphology", "Metabolism", "Physiology", "Immunology", "Hematology", "Heart", 
    "Hearing", "Eye", "All"))
heterog4$GroupingTerm <- factor(heterog4$GroupingTerm, rev(levels(heterog4$GroupingTerm)))
heterog4$label <- "All traits"
# write.csv(heterog4, 'heterog4.csv')

Plot S1 C (Second-order meta analysis on heterogeneity)

heterog5 <- heterog4
heterog5$mean <- as.numeric(exp(heterog5$value))
heterog5$ci.l <- as.numeric(exp(heterog5$ci.low))
heterog5$ci.h <- as.numeric(exp(heterog5$ci.high))

heterog6 <- heterog5

HeteroS1 <-
  heterog6 %>%
  ggplot(aes(y = GroupingTerm, x = mean)) +
  geom_errorbarh(aes(
    xmin = ci.l,
    xmax = ci.h
  ),
  height = 0.1, show.legend = FALSE
  ) +
  geom_point(aes(shape = parameter),
    fill = "black",
    color = "black", size = 2.2,
    show.legend = FALSE
  ) +
  scale_x_continuous(
    limits = c(-0.1, 1.4),
    # breaks = c(0, 0.1, 0.2),
    name = "sigma^2"
  ) +
  # geom_vline(xintercept=0,
  # color='black',
  # linetype='dashed')+
  facet_grid(
    cols = vars(parameter), rows = vars(label),
    labeller = label_wrap_gen(width = 23),
    scales = "free",
    space = "free"
  ) +
  theme_bw() +
  theme(
    strip.text.y = element_text(angle = 270, size = 10, margin = margin(t = 15, r = 15, b = 15, l = 15)),
    strip.text.x = element_text(size = 12),
    strip.background = element_rect(colour = NULL, linetype = "blank", fill = "gray90"),
    text = element_text(size = 14),
    panel.spacing = unit(0.5, "lines"),
    panel.border = element_blank(),
    axis.line = element_line(),
    panel.grid.major.x = element_line(linetype = "solid", colour = "gray95"),
    panel.grid.major.y = element_line(linetype = "solid", color = "gray95"),
    panel.grid.minor.y = element_blank(),
    panel.grid.minor.x = element_blank(),
    legend.title = element_blank(),
    axis.title.x = element_text(hjust = 0.5, size = 14),
    axis.title.y = element_blank()
  )

#HeteroS1

Combined Figure S1: overall Count data, Meta anlysis results, Heterogeneity)

FigS1 <- ggarrange(malebias_FigS1_alltraits + xlab("percentage sex bias"), Metameta_FigS1_alltraits, 
    HeteroS1, nrow = 3, align = "v", heights = c(1, 1, 1), labels = c("A", "B", 
        "C"))
FigS1

# ggsave('FigS1_OverallResults.pdf', plot = Fig4, width = 6, height = 5)

Figure S2

Plot FigS2 all significant results (CI not overlapping zero) for males ### FELIX: “ALL” missing. Felix added 11/2/2020: done

meta.plot2.sig.bS <- meta.plot2.sig[, c("lnCVR", "lnVR", "lnRR", "lnCVRsig", "lnVRsig", "lnRRsig", "GroupingTerm")]

meta.plot2.sig.cS <- gather(meta.plot2.sig.bS, trait, value, lnCVR:lnRR)
meta.plot2.sig.cS$sig <- "placeholder"

meta.plot2.sig.cS$trait <- factor(meta.plot2.sig.cS$trait, levels = c("lnCVR", "lnVR", "lnRR"))

meta.plot2.sig.cS$sig <- ifelse(meta.plot2.sig.cS$trait == "lnCVR", meta.plot2.sig.cS$lnCVRsig,
  ifelse(meta.plot2.sig.cS$trait == "lnVR", meta.plot2.sig.cS$lnVRsig, meta.plot2.sig.cS$lnRRsig)
)

# choosing sex biased ln-ratios significantly larger than 0
meta.plotS2.sig.malebias <- meta.plot2.sig.cS %>%
  group_by_at(vars(trait, GroupingTerm)) %>%
  filter(sig == 1) %>%
  summarise(male_sig = sum(value > 0), female_sig = sum(value < 0), total = male_sig + female_sig)

meta.plotS2.sig.malebias <- ungroup(meta.plotS2.sig.malebias) %>%
  add_row(trait = "lnCVR", GroupingTerm = "Hearing", male_sig = 0, female_sig = 0, .before = 4) %>% # add "Hearing" for lnCVR (not filtered as only zeros)
  mutate(malepercent = male_sig * 100 / total, femalepercent = female_sig * 100 / total)

meta.plotS2.sig.malebias$label <- "CI not overlapping zero"

# restructure to create stacked bar plots

meta.plotS2.sig.bothsexes <- as.data.frame(meta.plotS2.sig.malebias)
meta.plotS2.sig.bothsexes.b <- gather(meta.plotS2.sig.bothsexes, key = sex, value = percent, malepercent:femalepercent, factor_key = TRUE)

# create new sample size variable

meta.plotS2.sig.bothsexes.b$samplesize <- with(meta.plotS2.sig.bothsexes.b, ifelse(sex == "malepercent", male_sig, female_sig))

# Add summary row ('All') and re-arrange rows into correct order for plotting (warnings about coercing 'id' into character vector are ok)

meta.plotS2.sig.bothsexes.c <- meta.plotS2.sig.bothsexes.b %>% group_by(trait, sex) %>% 
  summarise(GroupingTerm = "All", male_sig = sum(male_sig), female_sig = sum(female_sig), total = male_sig + female_sig, 
            label = "CI not overlapping zero", samplesize = sum(samplesize)) %>%
  mutate(percent = ifelse(sex == "femalepercent", female_sig*100/(male_sig + female_sig), male_sig*100/(male_sig + female_sig))) %>%
  bind_rows(meta.plotS2.sig.bothsexes.b, .) %>%
  mutate(rownumber = row_number()) %>%
  .[c(55, 1:9, 57, 10:18, 59, 19:27, 56, 28:36, 58, 37:45, 60, 46:54), ] 

meta.plotS2.sig.bothsexes.c$GroupingTerm <- factor(meta.plotS2.sig.bothsexes.c$GroupingTerm, levels = c("Behaviour", "Morphology", "Metabolism", "Physiology", "Immunology", "Hematology", "Heart", "Hearing", "Eye", "All")) 
meta.plotS2.sig.bothsexes.c$GroupingTerm <- factor(meta.plotS2.sig.bothsexes.c$GroupingTerm, rev(levels(meta.plotS2.sig.bothsexes.c$GroupingTerm)))

# *Plot Fig2 all significant results (CI not overlapping zero):
#     no sig. lnCVR for 'Hearing' in either sex; no sig. male-biased lnCVR for 'Immunology' and 'Eye, and no sig. male-biased lnVR for 'Eye'

malebias_FigS2_sigtraits <-
  ggplot(meta.plotS2.sig.bothsexes.c) +
  aes(x = GroupingTerm, y = percent, fill = sex) +
  geom_col() +
  geom_hline(yintercept = 50, linetype = "dashed", color = "gray40") +
  geom_text(
    data = subset(meta.plotS2.sig.bothsexes.c, samplesize != 0), aes(label = samplesize), position = position_stack(vjust = .5),
    color = "white", size = 3.5
  ) +
  facet_grid(
    cols = vars(trait), rows = vars(label), labeller = label_wrap_gen(width = 18),
    scales = "free", space = "free"
  ) +
  scale_fill_brewer(palette = "Set2") +
  theme_bw(base_size = 18) +
  theme(
    strip.text.y = element_text(angle = 270, size = 10, margin = margin(t = 15, r = 15, b = 15, l = 15)),
    strip.text.x = element_text(size = 12),
    strip.background = element_rect(colour = NULL, linetype = "blank", fill = "gray90"),
    text = element_text(size = 14),
    panel.spacing = unit(0.5, "lines"),
    panel.border = element_blank(),
    axis.line = element_line(),
    panel.grid.major.x = element_line(linetype = "solid", colour = "gray95"),
    panel.grid.major.y = element_line(linetype = "solid", color = "gray95"),
    panel.grid.minor.y = element_blank(),
    panel.grid.minor.x = element_blank(),
    legend.position = "none",
    axis.title.x = element_blank(),
    axis.title.y = element_blank()
  ) +
  coord_flip()

# malebias_FigS2_sigtraits # this is Figure S2 A

Prepare data for traits with effect size ratios > 10% larger in males, supplemental Figure S2

FELIX: “ALL” missing. Felix added 11/2/2020: done

This Figure extends Figure 4, as it includes results not only for lnCVR and lnRR but also lnCVR. In addition, we compare two different assessments of sex-bias, significance (CI not overlapping zero) and sex differences in male / female ratios > 10%

Over 10% male bias, count data (first- order metanalysis)

meta.plot2.over10 <- meta_clean %>% select(lnCVR, lnVR, lnRR, GroupingTerm) %>% 
    arrange(GroupingTerm)

meta.plot2.over10.b <- gather(meta.plot2.over10, trait, value, c(lnCVR, lnVR, 
    lnRR))

meta.plot2.over10.b$trait <- factor(meta.plot2.over10.b$trait, levels = c("lnCVR", 
    "lnVR", "lnRR"))

meta.plot2.over10.c <- meta.plot2.over10.b %>% group_by_at(vars(trait, GroupingTerm)) %>% 
    summarise(malebias = sum(value > log(11/10)), femalebias = sum(value < log(9/10)), 
        total = malebias + femalebias, malepercent = malebias * 100/total, femalepercent = femalebias * 
            100/total)

meta.plot2.over10.c$label <- "Sex difference in m/f ratios > 10%"

# restructure to create stacked bar plots

meta.plot2.over10.c <- as.data.frame(meta.plot2.over10.c)
meta.plot2.over10.d <- gather(meta.plot2.over10.c, key = sex, value = percent, 
    malepercent:femalepercent, factor_key = TRUE)

# create new sample size variable

meta.plot2.over10.d$samplesize <- with(meta.plot2.over10.d, ifelse(sex == "malepercent", 
    malebias, femalebias))

# Add summary row ('All') and re-arrange rows into correct order for
# plotting (warnings about coercing 'id' into character vector are ok)

meta.plot2.over10.e <- meta.plot2.over10.d %>% group_by(trait, sex) %>% summarise(GroupingTerm = "All", 
    malebias = sum(malebias), femalebias = sum(femalebias), total = malebias + 
        femalebias, label = "Sex difference in m/f ratios > 10%", samplesize = sum(samplesize)) %>% 
    mutate(percent = ifelse(sex == "femalepercent", femalebias * 100/(malebias + 
        femalebias), malebias * 100/(malebias + femalebias))) %>% bind_rows(meta.plot2.over10.d, 
    .) %>% mutate(rownumber = row_number()) %>% .[c(55, 1:9, 57, 10:18, 59, 
    19:27, 56, 28:36, 58, 37:45, 60, 46:54), ]

meta.plot2.over10.e$GroupingTerm <- factor(meta.plot2.over10.e$GroupingTerm, 
    levels = c("Behaviour", "Morphology", "Metabolism", "Physiology", "Immunology", 
        "Hematology", "Heart", "Hearing", "Eye", "All"))
meta.plot2.over10.e$GroupingTerm <- factor(meta.plot2.over10.e$GroupingTerm, 
    rev(levels(meta.plot2.over10.e$GroupingTerm)))


# *Plot Fig2 Sex difference in m/f ratio > 10%
malebias_Fig2_over10 <- ggplot(meta.plot2.over10.e) + aes(x = GroupingTerm, 
    y = percent, fill = sex) + geom_col() + geom_hline(yintercept = 50, linetype = "dashed", 
    color = "gray40") + geom_text(data = subset(meta.plot2.over10.e, samplesize != 
    0), aes(label = samplesize), position = position_stack(vjust = 0.5), color = "white", 
    size = 3.5) + facet_grid(cols = vars(trait), rows = vars(label), labeller = label_wrap_gen(width = 18), 
    scales = "free", space = "free") + scale_fill_brewer(palette = "Set2") + 
    theme_bw(base_size = 18) + theme(strip.text.y = element_text(angle = 270, 
    size = 10, margin = margin(t = 15, r = 15, b = 15, l = 15)), strip.text.x = element_blank(), 
    strip.background = element_rect(colour = NULL, linetype = "blank", fill = "gray90"), 
    text = element_text(size = 14), panel.spacing = unit(0.5, "lines"), panel.border = element_blank(), 
    axis.line = element_line(), panel.grid.major.x = element_line(linetype = "solid", 
        colour = "gray95"), panel.grid.major.y = element_line(linetype = "solid", 
        color = "gray95"), panel.grid.minor.y = element_blank(), panel.grid.minor.x = element_blank(), 
    legend.position = "none", axis.title.x = element_blank(), axis.title.y = element_blank()) + 
    coord_flip()

# malebias_Fig2_over10 (supplemental Figure S2)

Fig S2, second-order meta-analysis, male traits

Female Figure, significant traits

Female FigS2 B sig

Prepare data for traits with CI not overlapping 0 create column with 1= different from zero, 0= zero included in CI

Restructure data for plotting

overall3.female.sigS <- gather(overall.female.plot3, parameter, value, c(lnCVR, lnVR, lnRR), factor_key = TRUE)

lnCVR.ci <- overall3.female.sigS %>%
  filter(parameter == "lnCVR") %>%
  mutate(ci.low = lnCVR_lower, ci.high = lnCVR_upper)
lnVR.ci <- overall3.female.sigS %>%
  filter(parameter == "lnVR") %>%
  mutate(ci.low = lnVR_lower, ci.high = lnVR_upper)
lnRR.ci <- overall3.female.sigS %>%
  filter(parameter == "lnRR") %>%
  mutate(ci.low = lnRR_lower, ci.high = lnRR_upper)

overall4.female.sigS <- bind_rows(lnCVR.ci, lnVR.ci, lnRR.ci) %>% select(GroupingTerm, parameter, value, ci.low, ci.high)

overall4.female.sigS$label <- "CI not overlapping zero"

##

Metameta_FigS2_female.sig <- overall4.female.sigS %>%
  ggplot(aes(y = GroupingTerm, x = value)) +
  geom_errorbarh(aes(
    xmin = ci.low,
    xmax = ci.high
  ),
  height = 0.1, show.legend = FALSE
  ) +
  geom_point(aes(shape = parameter),
    fill = "salmon1", color = "salmon1", size = 2.2,
    show.legend = FALSE
  ) +
  scale_x_continuous(
    limits = c(-0.4, 0),
    breaks = c(-0.3, 0),
    name = "Effect size"
  ) +
  geom_vline(
    xintercept = 0,
    color = "black",
    linetype = "dashed"
  ) +
  facet_grid(
    cols = vars(parameter), # rows = vars(label),
    # labeller = label_wrap_gen(width = 23),
    scales = "free",
    space = "free"
  ) +
  theme_bw() +
  theme(
    strip.text.y = element_text(angle = 270, size = 10, margin = margin(t = 15, r = 15, b = 15, l = 15)),
    strip.text.x = element_text(size = 12),
    strip.background = element_rect(colour = NULL, linetype = "blank", fill = "gray90"),
    text = element_text(size = 14),
    panel.spacing = unit(0.5, "lines"),
    panel.border = element_blank(),
    axis.line = element_line(),
    panel.grid.major.x = element_line(linetype = "solid", colour = "gray95"),
    panel.grid.major.y = element_line(linetype = "solid", color = "gray95"),
    panel.grid.minor.y = element_blank(),
    panel.grid.minor.x = element_blank(),
    legend.title = element_blank(),
    axis.title.x = element_blank(),
    axis.title.y = element_blank()
  )

# Metameta_FigS2_female.sig

Prepare data for traits with m/f difference > 10%

Create column with 1= larger, 0= difference not larger than 10% between male/female ratios

meta.male.plot3.perc <- metacombo %>% mutate(percCVR = ifelse(lnCVR > log(11/10), 
    1, 0), percVR = ifelse(lnVR > log(11/10), 1, 0), percRR = ifelse(lnRR > 
    log(11/10), 1, 0))

# Significant subset for lnCVR
metacombo_male.plot3.CVR.perc <- meta.male.plot3.perc %>% filter(percCVR == 
    1) %>% group_by(GroupingTerm) %>% nest()

metacombo_male.plot3.CVR.perc.all <- meta.male.plot3.perc %>% filter(percCVR == 
    1) %>% nest(data = everything())

# Significant subset for lnVR
metacombo_male.plot3.VR.perc <- meta.male.plot3.perc %>% filter(percVR == 1) %>% 
    group_by(GroupingTerm) %>% nest()

metacombo_male.plot3.VR.perc.all <- meta.male.plot3.perc %>% filter(percVR == 
    1) %>% nest(data = everything())

# Significant subset for lnRR
metacombo_male.plot3.RR.perc <- meta.male.plot3.perc %>% filter(percRR == 1) %>% 
    group_by(GroupingTerm) %>% nest()

metacombo_male.plot3.RR.perc.all <- meta.male.plot3.perc %>% filter(percRR == 
    1) %>% nest(data = everything())


# **Final fixed effects meta-analyses within grouping terms and across
# grouping terms, with SE of the estimate

plot3.male.meta.CVR.perc <- metacombo_male.plot3.CVR.perc %>% mutate(model_lnCVR = map(data, 
    ~metafor::rma.uni(yi = .x$lnCVR, sei = (.x$lnCVR_upper - .x$lnCVR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

plot3.male.meta.VR.perc <- metacombo_male.plot3.VR.perc %>% mutate(model_lnVR = map(data, 
    ~metafor::rma.uni(yi = .x$lnVR, sei = (.x$lnVR_upper - .x$lnVR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

plot3.male.meta.RR.perc <- metacombo_male.plot3.RR.perc %>% mutate(model_lnRR = map(data, 
    ~metafor::rma.uni(yi = .x$lnRR, sei = (.x$lnRR_upper - .x$lnRR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

# Across all grouping terms #

plot3.male.meta.CVR.perc.all <- metacombo_male.plot3.CVR.perc.all %>% mutate(model_lnCVR = map(data, 
    ~metafor::rma.uni(yi = .x$lnCVR, sei = (.x$lnCVR_upper - .x$lnCVR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

plot3.male.meta.CVR.perc.all <- plot3.male.meta.CVR.perc.all %>% mutate(GroupingTerm = "All")

plot3.male.meta.VR.perc.all <- metacombo_male.plot3.VR.perc.all %>% mutate(model_lnVR = map(data, 
    ~metafor::rma.uni(yi = .x$lnVR, sei = (.x$lnVR_upper - .x$lnVR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

plot3.male.meta.VR.perc.all <- plot3.male.meta.VR.perc.all %>% mutate(GroupingTerm = "All")

plot3.male.meta.RR.perc.all <- metacombo_male.plot3.RR.perc.all %>% mutate(model_lnRR = map(data, 
    ~metafor::rma.uni(yi = .x$lnRR, sei = (.x$lnRR_upper - .x$lnRR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

plot3.male.meta.RR.perc.all <- plot3.male.meta.RR.perc.all %>% mutate(GroupingTerm = "All")

# Combine with separate grouping term results

plot3.male.meta.CVR.perc <- bind_rows(plot3.male.meta.CVR.perc, plot3.male.meta.CVR.perc.all)
plot3.male.meta.VR.perc <- bind_rows(plot3.male.meta.VR.perc, plot3.male.meta.VR.perc.all)
plot3.male.meta.RR.perc <- bind_rows(plot3.male.meta.RR.perc, plot3.male.meta.RR.perc.all)


# **Re-structure data for each grouping term; delete un-used variables:
# 'Hearing missing for all 3 parameters'

plot3.male.meta.CVR.perc.b <- as.data.frame(plot3.male.meta.CVR.perc %>% group_by(GroupingTerm) %>% 
    mutate(lnCVR = map_dbl(model_lnCVR, pluck(2)), lnCVR_lower = map_dbl(model_lnCVR, 
        pluck(6)), lnCVR_upper = map_dbl(model_lnCVR, pluck(7)), lnCVR_se = map_dbl(model_lnCVR, 
        pluck(3))))[, c(1, 4:7)]
add.row.hearing <- as.data.frame(t(c("Hearing", NA, NA, NA, NA))) %>% setNames(names(plot3.male.meta.CVR.perc.b))
plot3.male.meta.CVR.perc.b <- rbind(plot3.male.meta.CVR.perc.b, add.row.hearing)
plot3.male.meta.CVR.perc.b <- plot3.male.meta.CVR.perc.b[order(plot3.male.meta.CVR.perc.b$GroupingTerm), 
    ]

plot3.male.meta.VR.perc.b <- as.data.frame(plot3.male.meta.VR.perc %>% group_by(GroupingTerm) %>% 
    mutate(lnVR = map_dbl(model_lnVR, pluck(2)), lnVR_lower = map_dbl(model_lnVR, 
        pluck(6)), lnVR_upper = map_dbl(model_lnVR, pluck(7)), lnVR_se = map_dbl(model_lnVR, 
        pluck(3))))[, c(1, 4:7)]
add.row.hearing <- as.data.frame(t(c("Hearing", NA, NA, NA, NA))) %>% setNames(names(plot3.male.meta.VR.perc.b))
plot3.male.meta.VR.perc.b <- rbind(plot3.male.meta.VR.perc.b, add.row.hearing)
plot3.male.meta.VR.perc.b <- plot3.male.meta.VR.perc.b[order(plot3.male.meta.VR.perc.b$GroupingTerm), 
    ]

plot3.male.meta.RR.perc.b <- as.data.frame(plot3.male.meta.RR.perc %>% group_by(GroupingTerm) %>% 
    mutate(lnRR = map_dbl(model_lnRR, pluck(2)), lnRR_lower = map_dbl(model_lnRR, 
        pluck(6)), lnRR_upper = map_dbl(model_lnRR, pluck(7)), lnRR_se = map_dbl(model_lnRR, 
        pluck(3))))[, c(1, 4:7)]
add.row.hearing <- as.data.frame(t(c("Hearing", NA, NA, NA, NA))) %>% setNames(names(plot3.male.meta.RR.perc.b))
plot3.male.meta.RR.perc.b <- rbind(plot3.male.meta.RR.perc.b, add.row.hearing)

add.row.eye <- as.data.frame(t(c("Eye", NA, NA, NA, NA))) %>% setNames(names(plot3.male.meta.RR.perc.b))
plot3.male.meta.RR.perc.b <- rbind(plot3.male.meta.RR.perc.b, add.row.eye)

plot3.male.meta.RR.perc.b <- plot3.male.meta.RR.perc.b[order(plot3.male.meta.RR.perc.b$GroupingTerm), 
    ]

plot3.male.meta.CVR.Vr.perc <- full_join(plot3.male.meta.CVR.perc.b, plot3.male.meta.VR.perc.b)
overall.male.plot3.perc <- full_join(plot3.male.meta.CVR.Vr.perc, plot3.male.meta.RR.perc.b)


overall.male.plot3.perc$GroupingTerm <- factor(overall.male.plot3.perc$GroupingTerm, 
    levels = c("Behaviour", "Morphology", "Metabolism", "Physiology", "Immunology", 
        "Hematology", "Heart", "Hearing", "Eye", "All"))
overall.male.plot3.perc$GroupingTerm <- factor(overall.male.plot3.perc$GroupingTerm, 
    rev(levels(overall.male.plot3.perc$GroupingTerm)))

Restructure data for plotting : Male biased, 10% difference

overall3.perc <- gather(overall.male.plot3.perc, parameter, value, c(lnCVR, 
    lnVR, lnRR), factor_key = TRUE)

lnCVR.ci <- overall3.perc %>% filter(parameter == "lnCVR") %>% mutate(ci.low = lnCVR_lower, 
    ci.high = lnCVR_upper)
lnVR.ci <- overall3.perc %>% filter(parameter == "lnVR") %>% mutate(ci.low = lnVR_lower, 
    ci.high = lnVR_upper)
lnRR.ci <- overall3.perc %>% filter(parameter == "lnRR") %>% mutate(ci.low = lnRR_lower, 
    ci.high = lnRR_upper)

overall4.male.perc <- bind_rows(lnCVR.ci, lnVR.ci, lnRR.ci) %>% select(GroupingTerm, 
    parameter, value, ci.low, ci.high)

overall4.male.perc$label <- "Sex difference in m/f ratios > 10%"

overall4.male.perc$value <- as.numeric(overall4.male.perc$value)
overall4.male.perc$ci.low <- as.numeric(overall4.male.perc$ci.low)
overall4.male.perc$ci.high <- as.numeric(overall4.male.perc$ci.high)

Plot Fig S2 all >10% difference (male bias) S2 B, bottom right

Metameta_Fig3_male.perc <- overall4.male.perc %>% # filter(., GroupingTerm != "Hearing") %>%
  ggplot(aes(y = GroupingTerm, x = value)) +
  geom_errorbarh(aes(
    xmin = ci.low,
    xmax = ci.high
  ),
  height = 0.1, show.legend = FALSE
  ) +
  geom_point(aes(
    shape = parameter,
    fill = parameter
  ),
  color = "mediumaquamarine", size = 2.2,
  show.legend = FALSE
  ) +
  scale_x_continuous(
    limits = c(-0.2, 0.62),
    breaks = c(0, 0.3),
    name = "Effect size"
  ) +
  geom_vline(
    xintercept = 0,
    color = "black",
    linetype = "dashed"
  ) +
  facet_grid(
    cols = vars(parameter), rows = vars(label),
    labeller = label_wrap_gen(width = 23),
    scales = "free",
    space = "free"
  ) +
  theme_bw() +
  theme(
    strip.text.y = element_text(angle = 270, size = 10, margin = margin(t = 15, r = 15, b = 15, l = 15)),
    strip.text.x = element_blank(),
    strip.background = element_rect(colour = NULL, linetype = "blank", fill = "gray90"),
    text = element_text(size = 14),
    panel.spacing = unit(0.5, "lines"),
    panel.border = element_blank(),
    axis.line = element_line(),
    panel.grid.major.x = element_line(linetype = "solid", colour = "gray95"),
    panel.grid.major.y = element_line(linetype = "solid", color = "gray95"),
    panel.grid.minor.y = element_blank(),
    panel.grid.minor.x = element_blank(),
    legend.title = element_blank(),
    axis.title.x = element_text(hjust = 0.5, size = 14),
    axis.title.y = element_blank()
  )

# Metameta_Fig3_male.perc (Figure S2 right panel)

Female Fig S2 >10%

meta.plot3.perc <- metacombo %>% mutate(percCVR = ifelse(lnCVR < log(9/10), 
    1, 0), percVR = ifelse(lnVR < log(9/10), 1, 0), percRR = ifelse(lnRR < log(9/10), 
    1, 0))

# Significant subset for lnCVR
metacombo_plot3.CVR.perc <- meta.plot3.perc %>% filter(percCVR == 1) %>% group_by(GroupingTerm) %>% 
    nest()

metacombo_plot3.CVR.perc.all <- meta.plot3.perc %>% filter(percCVR == 1) %>% 
    nest(data = everything())

# Significant subset for lnVR
metacombo_plot3.VR.perc <- meta.plot3.perc %>% filter(percVR == 1) %>% group_by(GroupingTerm) %>% 
    nest()

metacombo_plot3.VR.perc.all <- meta.plot3.perc %>% filter(percVR == 1) %>% nest(data = everything())

# Significant subset for lnRR
metacombo_plot3.RR.perc <- meta.plot3.perc %>% filter(percRR == 1) %>% group_by(GroupingTerm) %>% 
    nest()

metacombo_plot3.RR.perc.all <- meta.plot3.perc %>% filter(percRR == 1) %>% nest(data = everything())


# **Final fixed effects meta-analyses within grouping terms, with SE of the
# estimate

plot3.meta.CVR.perc <- metacombo_plot3.CVR.perc %>% mutate(model_lnCVR = map(data, 
    ~metafor::rma.uni(yi = .x$lnCVR, sei = (.x$lnCVR_upper - .x$lnCVR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

plot3.meta.VR.perc <- metacombo_plot3.VR.perc %>% mutate(model_lnVR = map(data, 
    ~metafor::rma.uni(yi = .x$lnVR, sei = (.x$lnVR_upper - .x$lnVR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

plot3.meta.RR.perc <- metacombo_plot3.RR.perc %>% mutate(model_lnRR = map(data, 
    ~metafor::rma.uni(yi = .x$lnRR, sei = (.x$lnRR_upper - .x$lnRR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

# Across all grouping terms #

plot3.meta.CVR.perc.all <- metacombo_plot3.CVR.perc.all %>% mutate(model_lnCVR = map(data, 
    ~metafor::rma.uni(yi = .x$lnCVR, sei = (.x$lnCVR_upper - .x$lnCVR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

plot3.meta.CVR.perc.all <- plot3.meta.CVR.perc.all %>% mutate(GroupingTerm = "All")

plot3.meta.VR.perc.all <- metacombo_plot3.VR.perc.all %>% mutate(model_lnVR = map(data, 
    ~metafor::rma.uni(yi = .x$lnVR, sei = (.x$lnVR_upper - .x$lnVR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

plot3.meta.VR.perc.all <- plot3.meta.VR.perc.all %>% mutate(GroupingTerm = "All")

plot3.meta.RR.perc.all <- metacombo_plot3.RR.perc.all %>% mutate(model_lnRR = map(data, 
    ~metafor::rma.uni(yi = .x$lnRR, sei = (.x$lnRR_upper - .x$lnRR_lower)/(2 * 
        1.96), control = list(optimizer = "optim", optmethod = "Nelder-Mead", 
        maxit = 1000), verbose = F)))

plot3.meta.RR.perc.all <- plot3.meta.RR.perc.all %>% mutate(GroupingTerm = "All")

# Combine with separate grouping term results

plot3.meta.CVR.perc <- bind_rows(plot3.meta.CVR.perc, plot3.meta.CVR.perc.all)
plot3.meta.VR.perc <- bind_rows(plot3.meta.VR.perc, plot3.meta.VR.perc.all)
plot3.meta.RR.perc <- bind_rows(plot3.meta.RR.perc, plot3.meta.RR.perc.all)


# **Re-structure data for each grouping term; delete un-used variables:
# 'Hearing missing for all 3 parameters'

plot3.meta.CVR.perc.b <- as.data.frame(plot3.meta.CVR.perc %>% group_by(GroupingTerm) %>% 
    mutate(lnCVR = map_dbl(model_lnCVR, pluck(2)), lnCVR_lower = map_dbl(model_lnCVR, 
        pluck(6)), lnCVR_upper = map_dbl(model_lnCVR, pluck(7)), lnCVR_se = map_dbl(model_lnCVR, 
        pluck(3))))[, c(1, 4:7)]
add.row.hearing <- as.data.frame(t(c("Hearing", NA, NA, NA, NA))) %>% setNames(names(plot3.meta.CVR.perc.b))
plot3.meta.CVR.perc.b <- rbind(plot3.meta.CVR.perc.b, add.row.hearing)
plot3.meta.CVR.perc.b <- plot3.meta.CVR.perc.b[order(plot3.meta.CVR.perc.b$GroupingTerm), 
    ]

plot3.meta.VR.perc.b <- as.data.frame(plot3.meta.VR.perc %>% group_by(GroupingTerm) %>% 
    mutate(lnVR = map_dbl(model_lnVR, pluck(2)), lnVR_lower = map_dbl(model_lnVR, 
        pluck(6)), lnVR_upper = map_dbl(model_lnVR, pluck(7)), lnVR_se = map_dbl(model_lnVR, 
        pluck(3))))[, c(1, 4:7)]
add.row.hearing <- as.data.frame(t(c("Hearing", NA, NA, NA, NA))) %>% setNames(names(plot3.meta.VR.perc.b))
plot3.meta.VR.perc.b <- rbind(plot3.meta.VR.perc.b, add.row.hearing)
plot3.meta.VR.perc.b <- plot3.meta.VR.perc.b[order(plot3.meta.VR.perc.b$GroupingTerm), 
    ]

plot3.meta.RR.perc.b <- as.data.frame(plot3.meta.RR.perc %>% group_by(GroupingTerm) %>% 
    mutate(lnRR = map_dbl(model_lnRR, pluck(2)), lnRR_lower = map_dbl(model_lnRR, 
        pluck(6)), lnRR_upper = map_dbl(model_lnRR, pluck(7)), lnRR_se = map_dbl(model_lnRR, 
        pluck(3))))[, c(1, 4:7)]
add.row.hearing <- as.data.frame(t(c("Hearing", NA, NA, NA, NA))) %>% setNames(names(plot3.meta.RR.perc.b))
plot3.meta.RR.perc.b <- rbind(plot3.meta.RR.perc.b, add.row.hearing)
add.row.hematology <- as.data.frame(t(c("Hematology", NA, NA, NA, NA))) %>% 
    setNames(names(plot3.meta.RR.perc.b))
plot3.meta.RR.perc.b <- rbind(plot3.meta.RR.perc.b, add.row.hematology)


plot3.meta.RR.perc.b <- plot3.meta.RR.perc.b[order(plot3.meta.RR.perc.b$GroupingTerm), 
    ]

plot3.meta.CVR.perc.c <- full_join(plot3.meta.CVR.perc.b, plot3.meta.VR.perc.b)
overall.plot3.perc <- full_join(plot3.meta.CVR.perc.c, plot3.meta.RR.perc.b)


overall.plot3.perc$GroupingTerm <- factor(overall.plot3.perc$GroupingTerm, levels = c("Behaviour", 
    "Morphology", "Metabolism", "Physiology", "Immunology", "Hematology", "Heart", 
    "Hearing", "Eye", "All"))
overall.plot3.perc$GroupingTerm <- factor(overall.plot3.perc$GroupingTerm, rev(levels(overall.plot3.perc$GroupingTerm)))

Restructure data for plotting Female bias, 10 percent difference

overall3.perc <- gather(overall.plot3.perc, parameter, value, c(lnCVR, lnVR, 
    lnRR), factor_key = TRUE)

lnCVR.ci <- overall3.perc %>% filter(parameter == "lnCVR") %>% mutate(ci.low = lnCVR_lower, 
    ci.high = lnCVR_upper)
lnVR.ci <- overall3.perc %>% filter(parameter == "lnVR") %>% mutate(ci.low = lnVR_lower, 
    ci.high = lnVR_upper)
lnRR.ci <- overall3.perc %>% filter(parameter == "lnRR") %>% mutate(ci.low = lnRR_lower, 
    ci.high = lnRR_upper)

overall4.perc <- bind_rows(lnCVR.ci, lnVR.ci, lnRR.ci) %>% select(GroupingTerm, 
    parameter, value, ci.low, ci.high)

overall4.perc$label <- "Sex difference in m/f ratios > 10%"

overall4.perc$value <- as.numeric(overall4.perc$value)
overall4.perc$ci.low <- as.numeric(overall4.perc$ci.low)
overall4.perc$ci.high <- as.numeric(overall4.perc$ci.high)

Plot FigS2 all >10% difference (female) Figure S2B, bottom left

Metameta_Fig3_female.perc <- overall4.perc %>%
  ggplot(aes(y = GroupingTerm, x = value)) +
  geom_errorbarh(aes(
    xmin = ci.low,
    xmax = ci.high
  ),
  height = 0.1, show.legend = FALSE
  ) +
  geom_point(aes(shape = parameter),
    fill = "salmon1", color = "salmon1", size = 2.2,
    show.legend = FALSE
  ) +

  # scale_shape_manual(values =

  scale_x_continuous(
    limits = c(-0.53, 0.2),
    breaks = c(-0.3, 0),
    name = "Effect size"
  ) +
  geom_vline(
    xintercept = 0,
    color = "black",
    linetype = "dashed"
  ) +
  facet_grid(
    cols = vars(parameter), # rows = vars(label),
    # labeller = label_wrap_gen(width = 23),
    scales = "free",
    space = "free"
  ) +
  theme_bw() +
  theme(
    strip.text.y = element_text(angle = 270, size = 10, margin = margin(t = 15, r = 15, b = 15, l = 15)),
    strip.text.x = element_blank(),
    strip.background = element_rect(colour = NULL, linetype = "blank", fill = "gray90"),
    text = element_text(size = 14),
    panel.spacing = unit(0.5, "lines"),
    panel.border = element_blank(),
    axis.line = element_line(),
    panel.grid.major.x = element_line(linetype = "solid", colour = "gray95"),
    panel.grid.major.y = element_line(linetype = "solid", color = "gray95"),
    panel.grid.minor.y = element_blank(),
    panel.grid.minor.x = element_blank(),
    legend.title = element_blank(),
    axis.title.x = element_text(hjust = 0.5, size = 14),
    axis.title.y = element_blank()
  )

# Metameta_Fig3_female.perc (Figure 5D left panel)

MISSING Metameta_Fig3_female.sig Metameta_Fig3_female.sig VR!!! # ADDED TO TEST #Metameta_FigS2_male.sig (Figure S2B top right panel)

Restructure MALE data for plotting

overall3.male.sigS <- gather(overall.male.plot3, parameter, value, c(lnCVR, 
    lnVR, lnRR), factor_key = TRUE)


lnCVR.ci <- overall3.male.sigS %>% filter(parameter == "lnCVR") %>% mutate(ci.low = lnCVR_lower, 
    ci.high = lnCVR_upper)
lnVR.ci <- overall3.male.sigS %>% filter(parameter == "lnVR") %>% mutate(ci.low = lnVR_lower, 
    ci.high = lnVR_upper)
lnRR.ci <- overall3.male.sigS %>% filter(parameter == "lnRR") %>% mutate(ci.low = lnRR_lower, 
    ci.high = lnRR_upper)

overall4.male.sigS <- bind_rows(lnCVR.ci, lnVR.ci, lnRR.ci) %>% select(GroupingTerm, 
    parameter, value, ci.low, ci.high)

overall4.male.sigS$label <- "CI not overlapping zero"

Plot FigS2 all significant results (CI not overlapping zero, male )

Metameta_FigS2_male.sig <- overall4.male.sigS %>% ggplot(aes(y = GroupingTerm, 
    x = value)) + geom_errorbarh(aes(xmin = ci.low, xmax = ci.high), height = 0.1, 
    show.legend = FALSE) + geom_point(aes(shape = parameter), fill = "mediumaquamarine", 
    color = "mediumaquamarine", size = 2.2, show.legend = FALSE) + scale_x_continuous(limits = c(0, 
    0.4), breaks = c(0, 0.3), name = "Effect size") + geom_vline(xintercept = 0, 
    color = "black", linetype = "dashed") + facet_grid(cols = vars(parameter), 
    rows = vars(label), labeller = label_wrap_gen(width = 23), scales = "free", 
    space = "free") + theme_bw() + theme(strip.text.y = element_text(angle = 270, 
    size = 10, margin = margin(t = 15, r = 15, b = 15, l = 15)), strip.text.x = element_text(size = 12), 
    strip.background = element_rect(colour = NULL, linetype = "blank", fill = "gray90"), 
    text = element_text(size = 14), panel.spacing = unit(0.5, "lines"), panel.border = element_blank(), 
    axis.line = element_line(), panel.grid.major.x = element_line(linetype = "solid", 
        colour = "gray95"), panel.grid.major.y = element_line(linetype = "solid", 
        color = "gray95"), panel.grid.minor.y = element_blank(), panel.grid.minor.x = element_blank(), 
    legend.title = element_blank(), axis.title.x = element_blank(), axis.title.y = element_blank())

# Metameta_FigS2_male.sig

Plot Fig S2: plots combined

Metameta_FigS2_female.sig

library(ggpubr)
FigS2b <- ggarrange(Metameta_FigS2_female.sig, Metameta_FigS2_male.sig, ncol = 2, 
    nrow = 1, widths = c(1, 1.2), heights = c(1, 1))

FigS2d <- ggarrange(Metameta_Fig3_female.perc, Metameta_Fig3_male.perc, ncol = 2, 
    nrow = 1, widths = c(1, 1.2), heights = c(1, 1))

# end combination Figure 5
FigS2 <- ggarrange(malebias_FigS2_sigtraits, malebias_Fig2_over10, FigS2b, FigS2d, 
    ncol = 1, nrow = 4, heights = c(2.3, 2, 2.1, 2), labels = c("A", " ", "B", 
        " "))
FigS2

NOT SURE WHAT THIS BELOW IS?? Felix added 11/2/2020: Ich glaube, dass das von vorher war. wenn wir alles oben haben, dann unten loeschen

Figure S2: sex-bias, including VR

Prepare data for traits with effect size ratios > 10% larger in males

meta.plotS2.over10 <- meta_clean %>% select(lnCVR, lnVR, lnRR, GroupingTerm) %>% 
    arrange(GroupingTerm)

meta.plotS2.over10.b <- gather(meta.plotS2.over10, trait, value, c(lnCVR, lnVR, 
    lnRR))

meta.plotS2.over10.b$trait <- factor(meta.plotS2.over10.b$trait, levels = c("lnCVR", 
    "lnVR", "lnRR"))

meta.plotS2.over10.c <- meta.plotS2.over10.b %>% group_by_at(vars(trait, GroupingTerm)) %>% 
    summarise(malebias = sum(value > log(11/10)), femalebias = sum(value < log(9/10)), 
        total = malebias + femalebias, malepercent = malebias * 100/total, femalepercent = femalebias * 
            100/total)

meta.plotS2.over10.c$label <- "Sex difference in m/f ratios > 10%"

# restructure to create stacked bar plots

meta.plotS2.over10.c <- as.data.frame(meta.plotS2.over10.c)
meta.plotS2.over10.d <- gather(meta.plotS2.over10.c, key = sex, value = percent, 
    malepercent:femalepercent, factor_key = TRUE)

# create new sample size variable

meta.plotS2.over10.d$samplesize <- with(meta.plotS2.over10.d, ifelse(sex == 
    "malepercent", malebias, femalebias))

# *Plot FigS2 Sex difference in m/f ratio > 10%
malebias_FigS2_over10 <- ggplot(meta.plotS2.over10.d) + aes(x = GroupingTerm, 
    y = percent, fill = sex) + geom_col() + geom_hline(yintercept = 50, linetype = "dashed", 
    color = "gray40") + geom_text(data = subset(meta.plot2.over10.d, samplesize != 
    0), aes(label = samplesize), position = position_stack(vjust = 0.5), color = "white", 
    size = 3.5) + facet_grid(cols = vars(trait), rows = vars(label), labeller = label_wrap_gen(width = 18), 
    scales = "free", space = "free") + scale_fill_brewer(palette = "Set2") + 
    theme_bw(base_size = 18) + theme(strip.text.y = element_text(angle = 270, 
    size = 10, margin = margin(t = 15, r = 15, b = 15, l = 15)), strip.text.x = element_blank(), 
    strip.background = element_rect(colour = NULL, linetype = "blank", fill = "gray90"), 
    text = element_text(size = 14), panel.spacing = unit(0.5, "lines"), panel.border = element_blank(), 
    axis.line = element_line(), panel.grid.major.x = element_line(linetype = "solid", 
        colour = "gray95"), panel.grid.major.y = element_line(linetype = "solid", 
        color = "gray95"), panel.grid.minor.y = element_blank(), panel.grid.minor.x = element_blank(), 
    legend.position = "none", axis.title.x = element_blank(), axis.title.y = element_blank()) + 
    coord_flip()

# malebias_FigS2_over10 #(Panel B in Fig S2 in ms)

#Metameta_FigS2_male.sig (Figure S2B top right panel)

Restructure MALE data for plotting

overall3.male.sigS <- gather(overall.male.plot3, parameter, value, c(lnCVR, 
    lnVR, lnRR), factor_key = TRUE)


lnCVR.ci <- overall3.male.sigS %>% filter(parameter == "lnCVR") %>% mutate(ci.low = lnCVR_lower, 
    ci.high = lnCVR_upper)
lnVR.ci <- overall3.male.sigS %>% filter(parameter == "lnVR") %>% mutate(ci.low = lnVR_lower, 
    ci.high = lnVR_upper)
lnRR.ci <- overall3.male.sigS %>% filter(parameter == "lnRR") %>% mutate(ci.low = lnRR_lower, 
    ci.high = lnRR_upper)

overall4.male.sigS <- bind_rows(lnCVR.ci, lnVR.ci, lnRR.ci) %>% select(GroupingTerm, 
    parameter, value, ci.low, ci.high)

overall4.male.sigS$label <- "CI not overlapping zero"

Plot FigS2 all significant results (CI not overlapping zero, male )

Metameta_FigS2_male.sig <- overall4.male.sigS %>% ggplot(aes(y = GroupingTerm, 
    x = value)) + geom_errorbarh(aes(xmin = ci.low, xmax = ci.high), height = 0.1, 
    show.legend = FALSE) + geom_point(aes(shape = parameter), fill = "mediumaquamarine", 
    color = "mediumaquamarine", size = 2.2, show.legend = FALSE) + scale_x_continuous(limits = c(0, 
    0.4), breaks = c(0, 0.3), name = "Effect size") + geom_vline(xintercept = 0, 
    color = "black", linetype = "dashed") + facet_grid(cols = vars(parameter), 
    rows = vars(label), labeller = label_wrap_gen(width = 23), scales = "free", 
    space = "free") + theme_bw() + theme(strip.text.y = element_text(angle = 270, 
    size = 10, margin = margin(t = 15, r = 15, b = 15, l = 15)), strip.text.x = element_text(size = 12), 
    strip.background = element_rect(colour = NULL, linetype = "blank", fill = "gray90"), 
    text = element_text(size = 14), panel.spacing = unit(0.5, "lines"), panel.border = element_blank(), 
    axis.line = element_line(), panel.grid.major.x = element_line(linetype = "solid", 
        colour = "gray95"), panel.grid.major.y = element_line(linetype = "solid", 
        color = "gray95"), panel.grid.minor.y = element_blank(), panel.grid.minor.x = element_blank(), 
    legend.title = element_blank(), axis.title.x = element_blank(), axis.title.y = element_blank())

# Metameta_FigS2_male.sig

10 % Perc sex difference, male bias

Restructure data for plotting : Male biased, 10% difference

overall3S.perc <- gather(overall.male.plot3.perc, parameter, value, c(lnCVR, 
    lnVR, lnRR), factor_key = TRUE)  # lnVR,

lnCVR.ci <- overall3S.perc %>% filter(parameter == "lnCVR") %>% mutate(ci.low = lnCVR_lower, 
    ci.high = lnCVR_upper)
lnVR.ci <- overall3S.perc %>% filter(parameter == "lnVR") %>% mutate(ci.low = lnVR_lower, 
    ci.high = lnVR_upper)
lnRR.ci <- overall3S.perc %>% filter(parameter == "lnRR") %>% mutate(ci.low = lnRR_lower, 
    ci.high = lnRR_upper)

overall4S.male.perc <- bind_rows(lnCVR.ci, lnVR.ci, lnRR.ci) %>% select(GroupingTerm, 
    parameter, value, ci.low, ci.high)  # lnVR.ci,

overall4S.male.perc$label <- "Sex difference in m/f ratios > 10%"

overall4S.male.perc$value <- as.numeric(overall4S.male.perc$value)
overall4S.male.perc$ci.low <- as.numeric(overall4S.male.perc$ci.low)
overall4S.male.perc$ci.high <- as.numeric(overall4S.male.perc$ci.high)

Plot FigS2 all >10% difference (male bias)

Metameta_FigS2_male.perc <- overall4S.male.perc %>% # filter(., GroupingTerm != "Hearing") %>%
  ggplot(aes(y = GroupingTerm, x = value)) +
  geom_errorbarh(aes(
    xmin = ci.low,
    xmax = ci.high
  ),
  height = 0.1, show.legend = FALSE
  ) +
  geom_point(aes(
    shape = parameter,
    fill = parameter
  ),
  color = "mediumaquamarine", size = 2.2,
  show.legend = FALSE
  ) +
  scale_x_continuous(
    limits = c(-0.2, 0.62),
    breaks = c(0, 0.3),
    name = "Effect size"
  ) +
  geom_vline(
    xintercept = 0,
    color = "black",
    linetype = "dashed"
  ) +
  facet_grid(
    cols = vars(parameter), rows = vars(label),
    labeller = label_wrap_gen(width = 23),
    scales = "free",
    space = "free"
  ) +
  theme_bw() +
  theme(
    strip.text.y = element_text(angle = 270, size = 10, margin = margin(t = 15, r = 15, b = 15, l = 15)),
    strip.text.x = element_blank(),
    strip.background = element_rect(colour = NULL, linetype = "blank", fill = "gray90"),
    text = element_text(size = 14),
    panel.spacing = unit(0.5, "lines"),
    panel.border = element_blank(),
    axis.line = element_line(),
    panel.grid.major.x = element_line(linetype = "solid", colour = "gray95"),
    panel.grid.major.y = element_line(linetype = "solid", color = "gray95"),
    panel.grid.minor.y = element_blank(),
    panel.grid.minor.x = element_blank(),
    legend.title = element_blank(),
    axis.title.x = element_text(hjust = 0.5, size = 14),
    axis.title.y = element_blank()
  )

# Metameta_FigS2_male.perc (Figure 5D right panel)

Restructure data for plotting: Female bias, 10 percent difference, including VR

overall3S.perc <- gather(overall.plot3.perc, parameter, value, c(lnCVR, lnVR, 
    lnRR), factor_key = TRUE)  # lnVR,

lnCVR.ci <- overall3S.perc %>% filter(parameter == "lnCVR") %>% mutate(ci.low = lnCVR_lower, 
    ci.high = lnCVR_upper)
lnVR.ci <- overall3S.perc %>% filter(parameter == "lnVR") %>% mutate(ci.low = lnVR_lower, 
    ci.high = lnVR_upper)
lnRR.ci <- overall3S.perc %>% filter(parameter == "lnRR") %>% mutate(ci.low = lnRR_lower, 
    ci.high = lnRR_upper)

overall4S.perc <- bind_rows(lnCVR.ci, lnVR.ci, lnRR.ci) %>% select(GroupingTerm, 
    parameter, value, ci.low, ci.high)

overall4S.perc$label <- "Sex difference in m/f ratios > 10%"

overall4S.perc$value <- as.numeric(overall4S.perc$value)
overall4S.perc$ci.low <- as.numeric(overall4S.perc$ci.low)
overall4S.perc$ci.high <- as.numeric(overall4S.perc$ci.high)

Plot Fig5D all >10% difference (female)

Metameta_Fig3S_female.perc <- overall4S.perc %>%
  ggplot(aes(y = GroupingTerm, x = value)) +
  geom_errorbarh(aes(
    xmin = ci.low,
    xmax = ci.high
  ),
  height = 0.1, show.legend = FALSE
  ) +
  geom_point(aes(shape = parameter),
    fill = "salmon1", color = "salmon1", size = 2.2,
    show.legend = FALSE
  ) +

  # scale_shape_manual(values =

  scale_x_continuous(
    limits = c(-0.53, 0.2),
    breaks = c(-0.3, 0),
    name = "Effect size"
  ) +
  geom_vline(
    xintercept = 0,
    color = "black",
    linetype = "dashed"
  ) +
  facet_grid(
    cols = vars(parameter), # rows = vars(label),
    # labeller = label_wrap_gen(width = 23),
    scales = "free",
    space = "free"
  ) +
  theme_bw() +
  theme(
    strip.text.y = element_text(angle = 270, size = 10, margin = margin(t = 15, r = 15, b = 15, l = 15)),
    strip.text.x = element_blank(),
    strip.background = element_rect(colour = NULL, linetype = "blank", fill = "gray90"),
    text = element_text(size = 14),
    panel.spacing = unit(0.5, "lines"),
    panel.border = element_blank(),
    axis.line = element_line(),
    panel.grid.major.x = element_line(linetype = "solid", colour = "gray95"),
    panel.grid.major.y = element_line(linetype = "solid", color = "gray95"),
    panel.grid.minor.y = element_blank(),
    panel.grid.minor.x = element_blank(),
    legend.title = element_blank(),
    axis.title.x = element_text(hjust = 0.5, size = 14),
    axis.title.y = element_blank()
  )

# Metameta_Fig3S_female.perc (Figure 5D left panel)

Figure S2

FigS2c <- ggarrange(Metameta_FigS2_female.sig, Metameta_FigS2_male.sig, ncol = 2, 
    nrow = 1, widths = c(1, 1.2), heights = c(1, 1))

FigS2d <- ggarrange(Metameta_Fig3S_female.perc, Metameta_FigS2_male.perc, ncol = 2, 
    nrow = 1, widths = c(1, 1.2), heights = c(1, 1))

# end combination Figure 5

FigS2 <- ggarrange(malebias_FigS2_sigtraits, malebias_FigS2_over10, FigS2c, 
    FigS2d, ncol = 1, nrow = 4, heights = c(2.2, 2, 2.2, 2), labels = c("A", 
        " ", "B", " "))
FigS2

Acknowledgements

tbd

R Session Information

sessionInfo()
## R version 3.6.0 (2019-04-26)
## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: macOS Mojave 10.14.6
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] here_0.1         ggpubr_0.2.1     magrittr_1.5     robumeta_2.0    
##  [5] kableExtra_1.1.0 forcats_0.4.0    stringr_1.4.0    tidyr_1.0.2     
##  [9] tibble_2.1.3     ggplot2_3.2.0    tidyverse_1.2.1  purrr_0.3.2     
## [13] devtools_2.1.0   usethis_1.5.1    metafor_2.1-0    Matrix_1.2-17   
## [17] dplyr_0.8.3      readr_1.3.1     
## 
## loaded via a namespace (and not attached):
##  [1] httr_1.4.0         pkgload_1.0.2      jsonlite_1.6      
##  [4] viridisLite_0.3.0  modelr_0.1.4       assertthat_0.2.1  
##  [7] cellranger_1.1.0   yaml_2.2.0         remotes_2.1.0     
## [10] sessioninfo_1.1.1  pillar_1.4.2       backports_1.1.4   
## [13] lattice_0.20-38    glue_1.3.1         digest_0.6.20     
## [16] RColorBrewer_1.1-2 ggsignif_0.5.0     rvest_0.3.4       
## [19] colorspace_1.4-1   plyr_1.8.4         cowplot_1.0.0     
## [22] htmltools_0.3.6    pkgconfig_2.0.2    broom_0.5.2       
## [25] haven_2.1.1        scales_1.0.0       webshot_0.5.1     
## [28] processx_3.4.0     generics_0.0.2     ellipsis_0.2.0.1  
## [31] withr_2.1.2        lazyeval_0.2.2     cli_1.1.0         
## [34] crayon_1.3.4       readxl_1.3.1       memoise_1.1.0     
## [37] evaluate_0.14      ps_1.3.0           fs_1.3.1          
## [40] nlme_3.1-140       xml2_1.2.1         pkgbuild_1.0.3    
## [43] tools_3.6.0        prettyunits_1.0.2  hms_0.5.0         
## [46] formatR_1.7        lifecycle_0.1.0    munsell_0.5.0     
## [49] callr_3.3.0        compiler_3.6.0     rlang_0.4.0       
## [52] grid_3.6.0         rstudioapi_0.10    labeling_0.3      
## [55] base64enc_0.1-3    rmarkdown_1.14     testthat_2.1.1    
## [58] codetools_0.2-16   gtable_0.3.0       reshape2_1.4.3    
## [61] R6_2.4.0           lubridate_1.7.4    knitr_1.23        
## [64] zeallot_0.1.0      rprojroot_1.3-2    desc_1.2.0        
## [67] stringi_1.4.3      Rcpp_1.0.1         vctrs_0.2.0       
## [70] tidyselect_0.2.5   xfun_0.8
LS0tCnRpdGxlOiAiSU1QQyBNb3VzZSBkYXRhIC0gVmFyaWFuY2UgaW4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GNpLmxvdywKICAgIHhtYXggPSBjaS5oaWdoCiAgKSwKICBoZWlnaHQgPSAwLjEsIHNob3cubGVnZW5kID0gRkFMU0UKICApICsKICBnZW9tX3BvaW50KGFlcyhzaGFwZSA9IHBhcmFtZXRlciksCiAgICBmaWxsID0gInNhbG1vbjEiLCBjb2xvciA9ICJzYWxtb24xIiwgc2l6ZSA9IDIuMiwKICAgIHNob3cubGVnZW5kID0gRkFMU0UKICApICsKCiAgIyBzY2FsZV9zaGFwZV9tYW51YWwodmFsdWVzID0KCiAgc2NhbGVfeF9jb250aW51b3VzKAogICAgbGltaXRzID0gYygtMC41MywgMC4yKSwKICAgIGJyZWFrcyA9IGMoLTAuMywgMCksCiAgICBuYW1lID0gIkVmZmVjdCBzaXplIgogICkgKwogIGdlb21fdmxpbmUoCiAgICB4aW50ZXJjZXB0ID0gMCwKICAgIGNvbG9yID0gImJsYWNrIiwKICAgIGxpbmV0eXBlID0gImRhc2hlZCIKICApICsKICBmYWNldF9ncmlkKAogICAgY29scyA9IHZhcnMocGFyYW1ldGVyKSwgIyByb3dzID0gdmFycyhsYWJlbCksCiAgICAjIGxhYmVsbGVyID0gbGFiZWxfd3JhcF9nZW4od2lkdGggPSAyMyksCiAgICBzY2FsZXMgPSAiZnJlZSIsCiAgICBzcGFjZSA9ICJmcmVlIgogICkgKwogIHRoZW1lX2J3KCkgKwogIHRoZW1lKAogICAgc3RyaXAudGV4dC55ID0gZWxlbWVudF90ZXh0KGFuZ2xlID0gMjcwLCBzaXplID0gMTAsIG1hcmdpbiA9IG1hcmdpbih0ID0gMTUsIHIgPSAxNSwgYiA9IDE1LCBsID0gMTUpKSwKICAgIHN0cmlwLnRleHQueCA9IGVsZW1lbnRfYmxhbmsoKSwKICAgIHN0cmlwLmJhY2tncm91bmQgPSBlbGVtZW50X3JlY3QoY29sb3VyID0gTlVMTCwgbGluZXR5cGUgPSAiYmxhbmsiLCBmaWxsID0gImdyYXk5MCIpLAogICAgdGV4dCA9IGVsZW1l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